myString = "THIS THING CAN KISS MY BUTT. HERE ARE MORE SSS";
myNewString = reReplace(myString, "[^0-9|^S{2}]", "|", "All");
myNewString is "|||S||||||||||||SS||||||||||||||||||||||||SSS
"
What I want is "||||||||||||||||SS|||||||||||||||||||||||||||
" which is what I thought ^S{2}
would do (exclude exactly 2 S
). Why is it matching any S? Can someone tell me how to fix it? TIA.
actual goal I'm trying to validate a list of values. Acceptable values would be 6 digit numbers or 5 digit numbers proceeded by SS so 123456,SS12345 is a valid list. what i'm trying to do is make everything that isn't SS or a number into a new delimiter because i have no control over the input. for example 123456 AND SS12345 should be changed to 123456|||||SS12345. after changing the | delimiter to , the result is 123456,SS12345. If a user were to enter 123456 PLUS SS12345 ends up with 123456||||S|SS12345 which = 123456,S,SS12345 which is invalid and the user gets an error, but it should be valid if it didn't match the single S.