Regular expression problem

Results 1 to 2 of 2

Thread: Regular expression problem

  1. #1
    Join Date
    Dec 1969

    Default Regular expression problem

    I am trying to parse a string and output all of the occurrences of text enclosed by # signs into a list. <BR><BR>i.e. <BR><BR>the string <BR>"some text some text #variable1# some text #variable2# some text #variable3# some text #variable4#"<BR><BR>would give the list<BR><BR>"variable1, variable2, variable3, variable4"<BR><BR><BR>Can anyone help me with this??<BR><BR>Thanks in advance<BR><BR>Ben H<BR>

  2. #2
    kpw Guest

    Default RE: Regular expression problem

    Are you using JavaScript or VBScript for this? The syntax is a little different, and I&#039;m a little rusty on how to iterate through all the matches of a given regular expression test.<BR><BR>In JavaScript, it would be something like this:<BR><BR>re = /#w+?#/g;<BR>result = re.test(expression);<BR>if (result)<BR>{<BR>// found some matches<BR><BR>// this next part is kind of shaky; don&#039;t take my word for it!<BR>for (i=0;i&#060;=result.length;i++)<BR>{<BR>alert(resu lt[i]);<BR>}<BR>}<BR><BR>Correct and modify as needed.<BR><BR>HTH

Posting Permissions

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