+ Reply to Thread
Results 1 to 9 of 9

RegExp function

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    Portland
    MS-Off Ver
    Excel 2003
    Posts
    8

    RegExp function

    Hi, I have a column with


    ABC (abc)
    XYZ (xyz)
    EDG (edg)
    ..


    Is there a way I can transform this column into an adjoining column that has only the values inside the brackets, so that the column looks like this:

    abc
    xyz
    edg
    ...


    I looked for regular expressions (regexp) help, but could not find an easy solution.

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    09-15-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    436

    Re: RegExp function

    Please try this function.

    =SUBSTITUTE(SUBSTITUTE(RIGHT(SUBSTITUTE(A1,"(",REPT("!",LEN(A1))),LEN(A1)),"!",""),")","")
    Please click 'Add reputation', if my answer helped you.

  3. #3
    Registered User
    Join Date
    10-12-2012
    Location
    Portland
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: RegExp function

    I tried this, just to use substrings, but this doesn't cover for text outside the brackets that may also have brackets.


    Please Login or Register  to view this content.
    The above thing works, except if my column was:

    ABC(something) (abc)
    XYZ (xyz)
    EDG (edg)
    ..

    I want this to return:

    abc
    xyz
    edg
    ..


    But the first one won't work due to multiple parantheses.

    Any suggestions? Thanks!

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,955

    Re: RegExp function

    based on your last post...you said you wanted the text inside (). Well if you have 2 (or 3 or more?) sets of (), how is excel supposed to know which set to pick?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    10-12-2012
    Location
    Portland
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: RegExp function

    Quote Originally Posted by ramananhrm View Post
    Please try this function.

    =SUBSTITUTE(SUBSTITUTE(RIGHT(SUBSTITUTE(A1,"(",REPT("!",LEN(A1))),LEN(A1)),"!",""),")","")


    Thanks so much Ramananhrm! That works! It also works with many parentheses repeated before the text I wish to extract, so it's exactly what I wanted. Much appreciate!

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: RegExp function

    Or

    For Single Iteration of () data

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,955

    Re: RegExp function

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Registered User
    Join Date
    10-12-2012
    Location
    Portland
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: RegExp function

    Quote Originally Posted by ramananhrm View Post
    Please try this function.

    =SUBSTITUTE(SUBSTITUTE(RIGHT(SUBSTITUTE(A1,"(",REPT("!",LEN(A1))),LEN(A1)),"!",""),")","")

    If you have a minute, could you please explain what this is doing? Thanks!

  9. #9
    Valued Forum Contributor
    Join Date
    09-15-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    436

    Re: RegExp function

    Step1: Wherever the "(" is placed within the sentance, a temp character is used to create a distance ( I have used "!")
    =SUBSTITUTE(A1,"(",REPT("!",LEN(A1)))

    Step2: The "!" is directing towards right/left
    =RIGHT(SUBSTITUTE(A1,"(",REPT("!",LEN(A1))),LEN(A1))

    Step3: Remove all the temp values using an additional 'Substitute' function
    =SUBSTITUTE(RIGHT(SUBSTITUTE(A1,"(",REPT("!",LEN(A1))),LEN(A1)),"!","")

    Step4: Finally use one more 'Substitute' function to remove the opposite bracket ie., ")"
    =SUBSTITUTE(SUBSTITUTE(RIGHT(SUBSTITUTE(A1,"(",REPT("!",LEN(A1))),LEN(A1)),"!",""),")","")

+ 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. 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
  2. VBScript.RegExp
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-27-2010, 09:20 PM
  3. RegExp
    By YBrazeau in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2010, 07:51 PM
  4. RegExp Pattern
    By MBCMDR in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2009, 02:09 PM
  5. [SOLVED] How do you look for two distinct patterns (RegExp)
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2005, 07:05 PM

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