Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MS Query capabilities/regex | New Users to Excel | |||
RegEx Replacement patterns | Excel Programming | |||
RegEx in VBE code editor | Excel Programming | |||
Regex Question | Excel Programming | |||
regex string matching | Excel Programming |