/Paula/ suffices.
? means: zero or one.
Applied in the way you do, that does not apply to the whole term Paula,
but only to its last LETTER: paulA
So, it means:
look for whatever that includes Paul
and that is followed either one or zero times by: "a".
First match that satisfies the condition is precisely Paul.
If you would have meant the ? quantifier to apply to the whole word,
sorround with round brackets the whole word it is meant to flag :
/(Paula)?/
YET beware that ALSO then it won't work the expected way: in fact, it
now means:
replace "Paula" IF it appears one or ZERO times
It would thus replace the first occurrence of the string where Paula is
not found, namely the vvery beginning of it and would yield:
GeorgePaul, Paula, Pauline
I hope this clarifies why it couldn't work.
Persoanlly, I'd suggest:
1) do not initialize like a regexp: place it right inside the replace
method:
myString.replace(/Paula/, "George");
2) You may want wehter to make iot global and case sensitive:
myString.replace(/Paula/gi, "George");
3) You may want to add a boundary delimiters (\b) before and after
Paula so to be sure it does not replace paula if by chance such a
string is in between a word (unlikely for a term like 'Paula', I
agree):
myString.replace(/\bPaula\b/gi, "George");
So your options are either (first preferred):
/\bPaula\b/gi
or just
/Paula/
ciao
Alberto
http://www.unitedscripters.com/