Skizit Skizit - 5 months ago 43
Javascript Question

Javascript string scanner?

I'm wondering, is there any way to scan a string in javascript.

e.g, I've got a string

abcdefdfdfssdfdssdffdq="HELLO"fdndkjdsnkjdnlkdfns
I'd like to scan that string and delete the characters between q=" and " and replace it with
GOODBYE
is this possible?

Answer

You can use string.replace(regexp/substr,newstring) As in: "abcdefdfdfssdfdssdffdq=\"HELLO\"fdndkjdsnkjdnlkdfns".replace(/".+"/, "\"GOODBYE\"")