+ Reply to Thread
Results 1 to 18 of 18

RegEx run time error! what is the wrong in the Pattern?

  1. #1
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Angry RegEx run time error! what is the wrong in the Pattern?

    Hello, the following function used for find and replace non-ascii whole string

    When i run the function i get run-time error 5017 Application-defined of object-defined. The error due to the positive lookbehind (?<=), but what is the wrong in syntax?

    Please Login or Register  to view this content.
    Last edited by exceere; 08-18-2021 at 01:05 AM.

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    Regular Expressions in vba doesn't have that functionality.

  3. #3
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    is ther an alternative to get the same fanctionality?

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    Yes, your simple solution solved the issue. YOU ARE GREATE.

    but, what does "$1" means?

    Thank you?

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    Do you understand the meaning of your original pattern?

  7. #7
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    Yes. Does $1 means restore the first letter in the match?

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    Refers to character(s) in first set of brackets.

  9. #9
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    Thanks.

    After i started test it, i notice the Pattern didn't match words at the beginning and end of the string.

    Please Login or Register  to view this content.
    Result:
    "Book Jonny Car Book"

    it didn't replace "Book" at beginning and "Book" at the end!

    How can i change the pattern to match, also, words at beginning and end?

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    What is your desire result?

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    So, you are using the pattern that you have.
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    Thank you.

    Desired Result: "Car Jonny Car Car"

    i used the function to replace arabic words, so \b dosn't work for me.
    Example:

    "كتاب جوني كتاب كتاب"

    i used english example just for simplify.

    so, desired result in Arabic:
    "سيارة جوني سيارة سيارة"

    Thanks

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    Then change the pattern to
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    Yes, Your are great jindon.

    I appreciate your valuable time and effort

  15. #15
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Question Re: RegEx run time error! what is the wrong in the Pattern?

    Hello,

    Now, how can i replace (), {}, [],<>.

    I get an error when i replace using follwing sub:

    Please Login or Register  to view this content.

    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,834

    Re: RegEx run time error! what is the wrong in the Pattern?

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    07-20-2012
    Location
    Kingdom of Saudi Arabia
    MS-Off Ver
    Excel 2016
    Posts
    103

    Re: RegEx run time error! what is the wrong in the Pattern?

    Hello, Thank you

    I think you mean

    Please Login or Register  to view this content.
    instead of

    Please Login or Register  to view this content.
    Tank you very much jindon.


    I appreciate your valuable time and effort.

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

    Re: RegEx run time error! what is the wrong in the Pattern?

    And unnecessary extra "(" by accident...

+ 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] Regex Pattern Matching
    By visualnotsobasic in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-16-2018, 09:56 PM
  2. [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
  3. RegEx - Pattern Matching
    By paularthur90 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2017, 09:16 AM
  4. Need to Define RegEx pattern
    By hmr2662 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-09-2015, 09:24 AM
  5. RegEx pattern
    By capson in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-15-2015, 06:57 PM
  6. [SOLVED] RegEx pattern, code exacuting but doing nothing
    By capson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2015, 03:48 PM
  7. Regex - establishing a pattern
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-30-2014, 11: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