+ Reply to Thread
Results 1 to 4 of 4

RegEx to parse something like this...

  1. #1
    R Avery
    Guest

    RegEx to parse something like this...

    Say i have text that has many tags which are enclosed within curly
    braces. For example,

    "asdlghjkshkg {HOHO} ghk48975 83y4, c98ty34 {NANA} fshdjh348679njc
    {ASDF} jdgghkjwer 435"

    Say I want to write a RegEx to extract all of these tags. I thought
    perhaps something like "(?[^{]*){([^}]*)})+" might work, but it does
    not seem to... strangely, it still matches the entire string, but i
    cannot get it to properly return all of the submatches.

    Any help would be appreciated.

  2. #2
    Gary Brown
    Guest

    RE: RegEx to parse something like this...

    Check out the answer to this question on Dec 20, 2004.

    http://groups-beta.google.com/group/...07ef0086240f46

    HTH,
    Gary Brown

    "R Avery" wrote:

    > Say i have text that has many tags which are enclosed within curly
    > braces. For example,
    >
    > "asdlghjkshkg {HOHO} ghk48975 83y4, c98ty34 {NANA} fshdjh348679njc
    > {ASDF} jdgghkjwer 435"
    >
    > Say I want to write a RegEx to extract all of these tags. I thought
    > perhaps something like "(?[^{]*){([^}]*)})+" might work, but it does
    > not seem to... strangely, it still matches the entire string, but i
    > cannot get it to properly return all of the submatches.
    >
    > Any help would be appreciated.
    >


  3. #3
    Daniel.M
    Guest

    Re: RegEx to parse something like this...

    Hi,

    This should populate your Matches collection with the proper strings (I don't
    know what you do with your results afterwards).

    Set regEx = CreateObject("VBScript.RegExp") ' Create a reg expr.
    regEx.Pattern = "\{[^{]*\}" ' Set pattern.
    regEx.IgnoreCase = True ' Set case insensitivity.
    regEx.Global = True ' Set global applicability.
    Set Matches = regEx.Execute(YourStringToProcess) ' Execute search.
    ' you can concatenate here

    Regards,

    Daniel M.


    "R Avery" <[email protected]> wrote in message
    news:[email protected]...
    > Say i have text that has many tags which are enclosed within curly
    > braces. For example,
    >
    > "asdlghjkshkg {HOHO} ghk48975 83y4, c98ty34 {NANA} fshdjh348679njc
    > {ASDF} jdgghkjwer 435"
    >
    > Say I want to write a RegEx to extract all of these tags. I thought
    > perhaps something like "(?[^{]*){([^}]*)})+" might work, but it does
    > not seem to... strangely, it still matches the entire string, but i
    > cannot get it to properly return all of the submatches.
    >
    > Any help would be appreciated.




  4. #4
    R Avery
    Guest

    Re: RegEx to parse something like this...

    Thanks.


    Gary Brown wrote:
    > Check out the answer to this question on Dec 20, 2004.
    >
    > http://groups-beta.google.com/group/...07ef0086240f46
    >
    > HTH,
    > Gary Brown
    >
    > "R Avery" wrote:
    >
    >
    >>Say i have text that has many tags which are enclosed within curly
    >>braces. For example,
    >>
    >>"asdlghjkshkg {HOHO} ghk48975 83y4, c98ty34 {NANA} fshdjh348679njc
    >>{ASDF} jdgghkjwer 435"
    >>
    >>Say I want to write a RegEx to extract all of these tags. I thought
    >>perhaps something like "(?[^{]*){([^}]*)})+" might work, but it does
    >>not seem to... strangely, it still matches the entire string, but i
    >>cannot get it to properly return all of the submatches.
    >>
    >>Any help would be appreciated.
    >>


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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