how to replace using a wildcard

Results 1 to 3 of 3

Thread: how to replace using a wildcard

  1. #1
    JohnH Guest

    Default how to replace using a wildcard

    I am attempting to replace replace a set of characters in a string, based on whether they are surrounded by a # character.<BR><BR>The String Variable "IndexVar" will contain a series of integer values, separated by commas, but I want to be able to remove values from the string when they are surrounded by the # character.<BR><BR>This code sample below successfully removes 4 (and its comma) from the string.<BR>&#060;%<BR>IndexVar = "1,2,3,^4^,5,6"<BR>IndexVar = Replace((IndexVar), "^4^,", "")<BR>%&#062;<BR><BR>However, I need to be able to remove ANY integer value by using a wildcard.<BR><BR>The code sample below- where I attempt to use * as a wildcard does NOT work<BR><BR>&#060;%<BR>IndexVar = "1,2,3,^4^,5,6"<BR>IndexVar = Replace((IndexVar), "^*^,", "")<BR>%&#062;<BR><BR>I COULD use a count variable in place of the wildcard, and create a loop for the number of repetitions neccesary to cover all possible values, but i consider that to be a terribly ugly kludge. Is there another way to do this?<BR><BR><BR>Any isnight on this would be greatly helpful.<BR>Thanks in advance.<BR>JH

  2. #2
    Join Date
    Dec 1969

    Default Use regular expressions..

    &nbsp;<BR>Replace does NOT support wildcards, at all.<BR><BR>See the VBScript version 5 docs and/or use JavaScript (you can call JS from VBS, you know, and I think JS regular expressions are done cleaner).<BR><BR>

  3. #3
    sigma Guest

    Default RE: how to replace using a wildcard

    You can use Javascript and use regular expression for a wildcard search and replace. Even VBScript version 5 supports regular expressions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts