+ Reply to Thread
Results 1 to 19 of 19

Search not pattern in regexp

  1. #1
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Search not pattern in regexp

    I have my udf
    In [A1]= i want in B1 find not my pattern 123 text123 with pattern reg.125-123456 and no 2 is reg.444-466669 then in B1=aa(a1,"[0-9]{3}-[0-9]{6}")
    Result after replace use " "
    In b1=i want in B1 result is pattern
    =125-123456 444-466669
    I dont Want my pattern replace become ""
    I want not pattern replace become ""
    Please Login or Register  to view this content.
    How i am use pattern become
    ^[0-9]{3}-^[0-9]{6}"
    Thank every body for your help
    Last edited by daboho; 12-01-2017 at 09:25 AM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,911

    Re: Search not pattern in regexp

    Upload sample workbook with several examples and your expected output please. I'm not sure that I understand your requirement.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Ck76 in [A1].value="Number 123 test is 444-123456"
    After i use my function udf
    In B1=aa(a1,"[0-9]{3}-[0-9]{6}")
    Result in B1 = "Number 123 test is"

    I want in B1 use my UDF =444-123456

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Search not pattern in regexp

    You could make a small change
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Xlnitwit yes like this haha thank but i want ask you
    If in a1= "pattern is 111-123456 and pattern 444-123456"
    The first my asking after use my udf
    I want i B1 = 111-123456 444-123456
    Second my asking
    After use udf B1=111-123456 and 444-123456
    Third my asking
    After use UDF
    In B1= 444-123456 ,C1=111-123456
    Thank before

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Search not pattern in regexp

    The first two can be done, but the third is not possible with a UDF unless you array enter it into as many cells as there could possibly be results.
    For the first two, use
    Please Login or Register  to view this content.
    the default separator is a space so
    =aa(A1,"[0-9]{3}-[0-9]{6}")
    will return your first request and
    =aa(A1,"[0-9]{3}-[0-9]{6}", " and ")
    your second.
    Last edited by xlnitwit; 12-01-2017 at 10:05 AM.

  7. #7
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Xlnitwit
    aa = .Execute(R.Value)(0)
    (0) = first pattern

    How if loop aa use sub aa()

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Search not pattern in regexp

    See the code in #6.

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

    Re: Search not pattern in regexp

    Quote Originally Posted by daboho View Post
    If in a1= "pattern is 111-123456 and pattern 444-123456"
    The first my asking after use my udf
    I want i B1 = 111-123456 444-123456
    Second my asking
    After use udf B1=111-123456 and 444-123456
    Third my asking
    After use UDF
    In B1= 444-123456 ,C1=111-123456
    Thank before
    1) =aa(A1,"\d{3}-\d{4}")
    2) =aa(A1,"\d{3}-\d{4}",,"and")
    3) =IFERROR(aa($A1,"\d{3}-\d{4}",COLUMN(A1)),"") then fill right
    Please Login or Register  to view this content.
    Last edited by jindon; 12-01-2017 at 10:32 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Ok thank xlnitwit
    I not see your code
    In your code
    Set matches = .Execute(R.Value)
    Store to variant matches
    Use set
    In array or string without use set
    Can explain me
    If i am looping matches use ubound stiil can do
    For example for i = ( 1 to ubound(matches))

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Search not pattern in regexp

    You use Set because the Execute method returns a MatchCollection2 object type. Ubound should not work.

  12. #12
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Hehe thankyou very match jindon glad see with you
    I want asking again
    In a1= "text pattern for 111-123456 and next pattern 444-123456"
    In Want in b1= text pattern for 111-123456
    I want first text in [a1] until 111-123456
    Can i am yse function in b1=left(a1,right(aa(a1,"\d{3}_\d{3}")))

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

    Re: Search not pattern in regexp

    Then the formula should be

    =aa(A1,".*?\d{3}-\d+")

    Edit

  14. #14
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Jindon hehe
    I has see internet about simbol in pattern but still confuse
    Can you please explain with pattern ".*?

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

    Re: Search not pattern in regexp

    .*? is a shortest match that follows each particular string,

    e.g

    .*?\d{3}-\d+ matches to 2 parts.

    text pattern for 111-123456 and next pattern 444-123456

    The function aa will only picks 1st match without ref named argument.

    If you change the formula to

    =aa($a1,".*?\d{3}-\d+",column(a1)) then fillright

    You will see each match.

  16. #16
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Jindon i has learn from google abaut pattern
    T$ = last caracter result IT from text "AT in IT
    a.a = result anp from anp is text

    But still not understand ". *?

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

    Re: Search not pattern in regexp

    Match in Regular Expression is always longest match.

    If the string = "abcd efg 123-444 and xyz 333-1234"

    It matches to whole with the pattern ".+\d{3}-\d+"
    .*? or .+? enables to match for each appearance of the pattern.

    Understand?

    BTW $ represents End of string so T$ only matches to T at the end of the string.

  18. #18
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,395

    Re: Search not pattern in regexp

    Ok thank jindon case closed
    As solved

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

    Re: Search not pattern in regexp

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. RegExp Pattern to remove special character
    By BS Singh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2014, 12:12 AM
  2. [SOLVED] Pattern Search
    By ssjagger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2012, 10:41 AM
  3. Error with Set RegExp equal to New RegExp vba
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-22-2011, 05:28 PM
  4. [SOLVED] Syntax to make long RegExp Pattern readable?
    By ahartman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2010, 02:25 PM
  5. Find string within string - a solution using RegExp.Pattern
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2010, 05:59 PM
  6. RegExp Pattern
    By MBCMDR in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2009, 02:09 PM
  7. [SOLVED] pattern matching w/o using VBScript's RegExp Object
    By Chris W. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2005, 06:06 PM

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