View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_2_] Robert Crandal[_2_] is offline
external usenet poster
 
Posts: 158
Default Another regular expression question

Hi Ron.... I only posted this question on the Excel VBA board
because I'm using regular expressions in Excel. I forgot that
I should NOT use "$" in my variable names. For now, assume that
my variable names will be "sItem" and "sDescription".

And yes, there is variation in my "item number", and I want to capture
the ENTIRE first token string, whether it be "Item4", "item_4", or even
"b6".
Our data format looks roughly like this:

"item number string" [option string description]

So, real examples a

Item1 scissors
Item2 two notebooks
item3
i4 keyboards and scissors
item_5 glue,paper,scissors
b6 broken keyboard


Sorry about the confusion. I hope I made it more clear now. Please
let me know if you need further clarification. Thank you.

Robert




"Ron Rosenfeld" wrote in message
...

Your question requires clarification for me to respond.

Since this is an Excel programming group, I would normally assume you are
writing about vbscript (essentially the same as Javascript) flavor of
regular expressions. Subgroup naming is not supported. But you could use
subgroups to save the relevant portions of your string, and then assign
them to variables within your VBA routine. However, VBA does not support
names which begin with "$".

If you are in the wrong group, there are flavors of regex that do support
variable naming but, at least in the .NET flavor, they do not begin with
the "$" as you have shown above. For example, in the .NET flavor, you
might have a named capturing group called ItemNum and would use it in a
replace string as $[ItemNum].

Also, there is considerable variation in your "item number" tokens, and it
is not clear if you want to capture only the number (which presumeably is
an integer), or the entire word. Nor is it clear what the extent of
variability in your item number tokens might be, or whether we could just
identify it more simply as merely (^"\w+\d+)

Item
item
itm
item_