### Thread: Need help supressing initial delimiter

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
5
Rep Power
0

#### Need help supressing initial delimiter

Using vbscript regex my match pattern uses several initial delimiters to find a match but I do not want to include the delimiter in the replace function.

My string is "Sources=e_PVin:PowerSupply1:Voltage:1.6,3.3,5.0,8.5,12,14.5:10:Always ON:0.5:0:DVM1:OFF"

My Patern is "([=;:])e_PVin(?=[:\W])"

Want to find and replace "e_PVin" with some other string.

example: "Sources=e_PVin(1):PowerSupply1:Voltage:1.6,3.3,5.0,8.5,12,14.5:10:Always ON:0.5:0:DVM1:OFF"
Last edited by requinix; August 3rd, 2011 at 12:38 PM. Reason: disabled smilies
2. And you need regular expressions for this? Are there going to be any "e_PVin"s that you don't want to replace?
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
5
Rep Power
0
Originally Posted by requinix
And you need regular expressions for this? Are there going to be any "e_PVin"s that you don't want to replace?
Don't want to replace anything that resembles "e_PVin" like "PVin", "e_Pvin_UVLO" etc.
4. Word \boundaries might be enough.
Code:
\be_PVin\b
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
5
Rep Power
0
Originally Posted by requinix
Word \boundaries might be enough.
Code:
\be_PVin\b
Cannot use boundy because it only works on word characters so in a case of "e_Vin_UVLO(1)" it will not match the whole string. In the first posting the pattern works with the exception where the string to replace is at the start of the line having no initial terminating character.
6. Meh.
You're already using lookaheads for the second delimiter; use a lookbehind for the first one:
Code:
(?<![=:;])e_PVin(?![:\W])
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
5
Rep Power
0
Originally Posted by requinix
Meh.
You're already using lookaheads for the second delimiter; use a lookbehind for the first one:
Code:
(?<![=:;])e_PVin(?![:\W])

The pattern you provided does not work, see below...
"Sources=e_PVin:PowerSupply1:Voltage:1.6,2.5,3.3,4.5,5.0,6,8.0,10,12,14,14.5:15"
8. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
5
Rep Power
0
Originally Posted by requinix
And what am I looking at?
The first parameter may have may contain delimiters "=:;" or it may start with no delimiter. So in the case above PVin starts with a "=" delimiter but the regex does not find a match.

I think this pattern works but I am not sure the significance of the "*"
"([=;:])*e_PVin(?=[:\W])"