+ Reply to Thread
Results 1 to 10 of 10

Regex - establishing a pattern

  1. #1
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174

    Regex - establishing a pattern

    Hello -

    With regex, can you set the pattern based on number of digits in a string?

    Here is the code I have so far:

    The objective is to extract each character, if you find a pattern with 3, 4, 5 integers and a space, set it to your pattern.
    If you find the pattern again, set it to new line.

    Please Login or Register  to view this content.
    The code is not complete and may be off but I will continue to research this.

    A file is attached with desired result on bottom.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Regex - establishing a pattern

    I know basic of Reg expression, but if you want the pattern to start with numbers, I thought
    Please Login or Register  to view this content.

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

    Re: Regex - establishing a pattern

    Quote Originally Posted by AB33 View Post
    I know basic of Reg expression, but if you want the pattern to start with numbers, I thought
    Please Login or Register  to view this content.
    Better not post from your guess that is completely wrong.


    twckfa16

    If you lookif for the pattern which match to 3 to 5 degits numbers then
    Please Login or Register  to view this content.
    However, your code is not utilizing RegExp and even doesn't compile.

    What are you trying to do?

  4. #4
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174

    Re: Regex - establishing a pattern

    I know it doesn't compile

    For example, if you have the following strings in cells A1 and A2:

    1443 some text here1444 plus 1 more test
    1445 some text here 1446 plus (1 to 15)

    You get the results in cells A3 thru A6(doesn't really matter):
    1443 some text here
    1444 plus 1 more test
    1445 some text here
    1446 plus (1 to 15)

    Thank you

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

    Re: Regex - establishing a pattern

    Output the results in col.B
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174

    Re: Regex - establishing a pattern

    Jindon - Thank you very much for what you supplied here. Got much further than I would have expected.

    I noticed that when I changed

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    ...the output changes. is there a way to determine if they're are so many digits before a charater, pattern equals 3 or 4 etc.

    Thank you again!

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

    Re: Regex - establishing a pattern

    Not really sure what you are trying.
    Perhaps.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174

    Re: Regex - establishing a pattern

    I can try that. Basically, the three and four digit work good.
    If you have 6 or 8 digits - they will need to be halved.

    So if you have:

    12345678nnn in one cell, that should be:

    1234
    5678nnn

    Or if you have 123456, that should be
    123
    456

    Is there something that can determine number of digits, and then change the pattern accordingly if you need to ?

    Thanks

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

    Re: Regex - establishing a pattern

    What about

    12345xx

  10. #10
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2007
    Posts
    174

    Re: Regex - establishing a pattern

    I havent encountered that yet but may need in the future.

    I just saw one line with this pattern:

    123sometexthere123sometexthere123sometexthere123sometexthere123sometexthere

+ 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 to extract multiplelines title in TXT file
    By p24leclerc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2014, 08:39 PM
  2. [SOLVED] Establishing 20:80 Ratio
    By mycon73 in forum Excel General
    Replies: 3
    Last Post: 03-03-2013, 08:35 PM
  3. Need a new regex .pattern for comparison code
    By Swiss Cheese in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 09:16 PM
  4. Establishing Duplicates & New
    By kirtletheturtle in forum Excel General
    Replies: 2
    Last Post: 10-14-2009, 08:04 AM
  5. [SOLVED] Re-establishing Links
    By Me in forum Excel General
    Replies: 0
    Last Post: 12-09-2005, 12:10 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