Replacing text with a variable

Results 1 to 2 of 2

Thread: Replacing text with a variable

  1. #1
    Join Date
    Dec 1969

    Default Replacing text with a variable

    Assuming code like this :<BR><BR>Function stripHTML1(strHTML)<BR> Dim objRegExp, strOutput<BR> Set objRegExp = New Regexp<BR> objRegExp.IgnoreCase = True<BR> objRegExp.Global = True<BR> objRegExp.Pattern = "[(.*?)]"<BR> strOutput = objRegExp.Replace(strHTML, "$1")<BR> stripHTML1 = strOutput<BR> Set objRegExp = Nothing<BR>End Function<BR><BR>How would I replace a found pattern, with the variable that represents that pattern in a text string.<BR><BR>eg - find the text [address] and replace it with the actual value of the variable "address"<BR><BR>So, instead of this :<BR>strOutput = objRegExp.Replace(strHTML, "$1")<BR><BR>I really want to do something like this :<BR>strOutput = objRegExp.Replace(strHTML, $1)<BR><BR>Make sense? :)<BR><BR>Cheers,<BR>Dave<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Replacing text with a variable

    I believe this is what you&#039;re asking:<BR><BR>You have a variable called "address", i.e. Dim address. This variable has some address value in it (email/web).<BR><BR>You want to search for the pattern: [(.*?)] in your text string. The submatch $1 will be the name of an actual variable that has the address value in it. You want to evalues the string in $1 (via RegExp object) as an actual variable name.<BR><BR>I&#039;ve used Eval() to evaluate strings as call to functions, i.e. ret = Eval("getNames") -&#062; ret = getNames()<BR><BR>Try it to reference a variable and see if it works.

Posting Permissions

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