0

I want to find the "(*" string in another string and then replace it with the < and / one but the method replace() can not do it. Sorry, but I can not write the string in the description together :D

Here is my code:

//Call the method like..
trace(searchandreplace("(*Foo)"));

  private function searchandreplace(input:String):String{
    var pattern:RegExp = /(*/gi;
    return input.replace(pattern,"</");
  }

Trace: //What I get:..
"(*Foo)"

Trace: //What I want...
"</Foo>"

It would be nice if someone can fix my problem.

Thanks in advance!

1 Answer 1

2

You need to mask "(" and "*" in your pattern:

var pattern:RegExp = /\(\*/gi;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.