Roderick_E
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 2,051
Hi old friends, been a while since I've been on here; they got me learning python at work. Anyhow, I'm trying to create a VBA with regex-like abilities.
I want to look at a string and parse all <*> (ie, <someword>) and replace it with the word as a variable.
Example:
Hello <username>,
We are glad you are posting to Mr.Excel on <date>
I want to parse and find all uses of <> and in those places used the defined variable within the VBA
VBA sample:
username = "Bob"
datestr = format(now(),"Short Date")
regexstr = replace(replace(regexstr,"<username>",username),"<date>",datestr)
----
However I don't want to define each and every place to replace so I need to loop through the regexstr and find any place with <...> and replace with it's variable if defined otherwise just leave the <...> in place.
Help please?
I want to look at a string and parse all <*> (ie, <someword>) and replace it with the word as a variable.
Example:
Hello <username>,
We are glad you are posting to Mr.Excel on <date>
I want to parse and find all uses of <> and in those places used the defined variable within the VBA
VBA sample:
username = "Bob"
datestr = format(now(),"Short Date")
regexstr = replace(replace(regexstr,"<username>",username),"<date>",datestr)
----
However I don't want to define each and every place to replace so I need to loop through the regexstr and find any place with <...> and replace with it's variable if defined otherwise just leave the <...> in place.
Help please?