#1
  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. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    And you need regular expressions for this? Are there going to be any "e_PVin"s that you don't want to replace?
  4. #3
  5. 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.
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    Word \boundaries might be enough.
    Code:
    \be_PVin\b
  8. #5
  9. 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.
  10. #6
  11. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    Meh.
    You're already using lookaheads for the second delimiter; use a lookbehind for the first one:
    Code:
    (?<![=:;])e_PVin(?![:\W])
  12. #7
  13. 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"
  14. #8
  15. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
  16. #9
  17. 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])"

IMN logo majestic logo threadwatch logo seochat tools logo