+ Reply to Thread
Results 1 to 10 of 10

Excel REGEX SEARCH Function

  1. #1
    Registered User
    Join Date
    07-27-2022
    Location
    Bangladesh
    MS-Off Ver
    365
    Posts
    5

    Question Excel REGEX SEARCH Function

    Hi good people! I need to create a RegEx function that will work the same way Excel SEARCH or FIND function works.
    For example, the SEARCH function returns the position of a part of text within a string.
    I want a RegEx SEARCH function that will match a pattern and return the location of the pattern within a string.
    Anybody can help, please?
    186.png
    Last edited by Masum_Mahdy; 12-08-2022 at 05:59 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Excel REGEX SEARCH Function


    Hi,

    just use the VBA text function Instr

  3. #3
    Registered User
    Join Date
    07-27-2022
    Location
    Bangladesh
    MS-Off Ver
    365
    Posts
    5

    Re: Excel REGEX SEARCH Function

    I am not good at VBA. Does this function support pattern? Can you please elaborate?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Excel REGEX SEARCH Function


    According to cell B2 as it is a 'pattern' is not necessary, whatever combining Instr & InstrRev or just using Split as explained in VBA help.
    And directly with an Excel worksheet function rather than VBA.

    For other cases then you may need such 'pattern' …

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Excel REGEX SEARCH Function

    Are you required to use or be compatible with Excel? If not, Google sheets has built in functions for working with regular expressions that should be useful for your project: https://www.benlcollins.com/spreadsh...egex-formulas/
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,377

    Re: Excel REGEX SEARCH Function

    Rexex is not a good subject to start with if you are willing to learn VBA. It's hard to read/understand. But check this out (If it is always just one email, you can remove ".Global = true", now it finds every email in the string)

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    Last edited by JEC.; 12-08-2022 at 04:00 PM.

  7. #7
    Registered User
    Join Date
    07-27-2022
    Location
    Bangladesh
    MS-Off Ver
    365
    Posts
    5

    Re: Excel REGEX SEARCH Function

    Thanks, MrShorty! Definitely, I will try this too.

  8. #8
    Registered User
    Join Date
    07-27-2022
    Location
    Bangladesh
    MS-Off Ver
    365
    Posts
    5

    Re: Excel REGEX SEARCH Function

    Thanks, JEC. That's life-saving. Can I use this elsewhere with proper credit (with thread link) to you/your forum?

  9. #9
    Registered User
    Join Date
    07-27-2022
    Location
    Bangladesh
    MS-Off Ver
    365
    Posts
    5

    Re: Excel REGEX SEARCH Function

    Thank you, Marc L. My problem is solved! Credit goes to JEC!

  10. #10
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,377

    Re: Excel REGEX SEARCH Function

    You’re welcome! Sure, you can

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Instr with RegEx - Runtime error 5017 (RegEx Code provided)
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2018, 05:02 PM
  2. help with regex function for extract numbers out
    By Pancho3 in forum Excel General
    Replies: 4
    Last Post: 09-21-2018, 02:56 PM
  3. [SOLVED] help with a function using Regex
    By Pancho3 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2016, 09:22 PM
  4. Read .PDF attachment, search for RegEx.Pattern
    By Anxiety in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2016, 12:13 PM
  5. Passing a RegEx to a function
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-31-2014, 06:12 AM
  6. Search String and Return Static Value (Like CASE + RegEX in SQL)
    By digitalnoise in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2012, 11:21 PM
  7. Search and replace(Regex) in string in array.
    By VBABen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2011, 09:21 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1