+ Reply to Thread
Results 1 to 33 of 33

Regex exact match function

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Regex exact match function

    Hi,

    i am using this code which is failing:

    Please Login or Register  to view this content.
    Runtime Error 5020...

    Why?

    How to find exact match within string above using regex?

    Please help,
    Jacek
    Attached Files Attached Files

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    Why use RegEx for that? Just use Instr or Like.
    Rory

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    hi Rory,

    thank you.
    Because i do not know how to use instr with it.

    in textString i have 2 indirects formulas so i want to skip this.
    How can i write a statement for this?

    What i have is Table Name from dictionary.

    Jacek

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    Please Login or Register  to view this content.
    would be True if the text is found.

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    ok thank you.

    but in this case it will work every time i have indirect formula there.
    I want to catch when i have at least one table name without indirect.

    What if i have:

    textString = "=INDEX(T_DATACENTERSSOURCE[DATACENTER]),MATCH([@RegionName],INDIRECT(""T_DATACENTERSSOURCE[LOCATIONID]""),0))"

    so one is indirect, one is not indirect and i have to have TRUE here and go further (not skip).

    Best,
    Jacek

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    That's not what your original code would have done. You can use Like and test for the table name without a quotation mark in front of it:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    thank you Rory!

    what is this in your code?:

    "["

    Jacek

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    It's a character group, much like in RegEx.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    very nice,

    thank you!

    this is so many exceptions here.
    i need regex for this i think.

    for example i have "T_ser" and looking within "T_serdetails".

    in this formula:

    textstring Like "*[!""]T_serdetails*" it will match but it shouldn't because i have different exact matched string...

    Please help,
    Jacek

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    Hi,

    anyone?

    Jacek

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Regex exact match function

    To answer your question on Post #1 : Why Rutime Error ?

    Because :

    Please Login or Register  to view this content.
    the opening bracket is part of Regex's "Special Characters" used for grouping, so if you mean the actual opening bracket sign, you must escape it like this :

    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  12. #12
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    hi,

    thank you.

    Ok this is still not working for me.

    the goal is:

    if i have at least one indirect within formula - skip the formula. (set function to false).

    Rory provided solution how to check if indirect is there:
    If we have table name with quotation mark - skip because this is indirect.

    i tried use this code:

    Please Login or Register  to view this content.
    but pattern is not working. I can not delete the last quotation mark:

    Screenshot_11.png

    Please help with this,
    Jacek
    Attached Files Attached Files

  13. #13
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Regex exact match function

    Why still not with InStr:
    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  14. #14
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    thank you KOKOSEK,

    because if i will have table name like "T_DATACENTERS" it should not find it because it would be not exact match.
    Instr will find evenr part of the string.

    Jacek

  15. #15
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    You're missing a quote:

    Please Login or Register  to view this content.

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Regex exact match function


  17. #17
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Regex exact match function

    Still confused, by your description, try this :

    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    thank you Rory! (sorry i can not add reputation to you i am adding it too often).
    Working like a charm.

    Ok and if i want to find out if there is exact table name but WITHOUT preceding quotation mark (so at least one no indirect table reference in formula), how the pattern will be look like?

    i tried with:

    Please Login or Register  to view this content.
    but this is throwing error.

    Please help,
    Jacek

  19. #19
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    karedog, thank you!

    Can you please explain this pattern?

    Please Login or Register  to view this content.
    \W - special character
    what is "\" doing ?

    Jacek

  20. #20
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    jindon, thanks!

    how would you use this strcomp function together with instr?

    It would be nice solution somehow?

    Jacek

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Regex exact match function

    Use it instead of Instr like
    Please Login or Register  to view this content.

  22. #22
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Regex exact match function

    You are welcome, thanks for reps.

    You want an exact match, so :

    INDIRECT(""T_DATACENTERSSOURCE[DATACENTER]
    should be matched

    and

    INDIRECT(""T_DATACENTERSSOURCExxx[DATACENTER]
    should not be matched

    To distinguish between them, in your case, there is direct "opening square bracket character [" immediately after the table name, and it is part of Regex's \W range.

  23. #23
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    karedog,

    thank you.

    jindon, thank you,
    but this is not wotking

    i tried with:

    Please Login or Register  to view this content.
    and with :
    PatternToFind = """" & tablename

    but still is not = 0...

    Jacek

  24. #24
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Regex exact match function

    I didn't read the problem carefully,
    Perhaps [ at the end of variable like
    Please Login or Register  to view this content.
    Then InStr Function ?

  25. #25
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    thanks, the solution was provided by Rory with regex function.

    All other methos will work but i have a lot of cases so regex working the best.

    Question is one:

    Please Login or Register  to view this content.
    How to:

    Ok and if i want to find out if there is exact table name but WITHOUT preceding quotation mark (so at least one no indirect table reference in formula), how the pattern will be look like?
    i tried with:

    Please Login or Register  to view this content.
    but i failed.

    Jacek

  26. #26
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    This is very difficult.

    I tried also with this one link:

    https://www.regextester.com/15

    Screenshot_12.png

    as you can see i didn't find a word ""badword" here so it is working fine.

    but when i moved it to pattern:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    this is giving false witgin Regex function...

    Please help,
    Jacek

  27. #27
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    Remove the two / characters.

  28. #28
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    thank you Rory,

    not working

    Please Login or Register  to view this content.
    it should give me a TRUE here...

    Jacek

  29. #29
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Regex exact match function

    That / should be \

  30. #30
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    Still i am getting FALSE :/

    Please Login or Register  to view this content.

  31. #31
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    After spending a lot of hours on it i have!!!

    Please Login or Register  to view this content.
    thank you!

    Jacek

  32. #32
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    Ok this is still not working

    this is not looking for exact match!

    Please Login or Register  to view this content.
    this should be false because i have within lookup string T_DATACENTERSSOURCE , not T_DATACENTERS...

    Please help,
    Jacek

  33. #33
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Regex exact match function

    problem solved:

    Please Login or Register  to view this content.

+ 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] Found function with exact match
    By bimo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-06-2014, 04:27 AM
  2. FIND function exact match
    By kgolding in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 12-13-2013, 10:41 AM
  3. [SOLVED] Exact text match within a SUMIF function
    By afgoody in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-17-2013, 11:35 PM
  4. Replies: 3
    Last Post: 06-17-2013, 12:37 PM
  5. [SOLVED] Exact Value match in Lookup function
    By cdjindia in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-28-2012, 08:48 AM
  6. Filter function - exact match...
    By pmguerra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2006, 09:48 AM
  7. MATCH function - 2 columns w/ SIMILAR, not EXACT data
    By Jane in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2005, 12:06 AM

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