Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Query capabilities/regex Mike[_10_] New Users to Excel 2 June 23rd 08 09:19 PM
RegEx Replacement patterns CodeSponge[_2_] Excel Programming 2 February 5th 05 07:39 AM
RegEx in VBE code editor R Avery Excel Programming 6 December 21st 04 01:58 PM
Regex Question William Barnes Excel Programming 5 January 2nd 04 11:57 AM
regex string matching Jamie Martin[_2_] Excel Programming 3 September 26th 03 09:28 PM


All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"