0

Will this effectively delete strings like: t_someString, o_someString, a_someString etc? I don't know what the first character is going to be, _someString is the only known factor

.replace( \*\ + '_someString', '' )

2
  • 2
    huh? what's with the backslashes? not sure what you're doing... Commented Dec 19, 2013 at 21:53
  • You're doing it wrong. Commented Dec 19, 2013 at 21:59

1 Answer 1

2

Huh? What's with the backslashes? And the asterisk? And the plus sign? Not sure what you're doing....

Anyway, here's a regex for that:

yourString = yourString.replace(/._someString/g, '')

. means "any character". The g flag is for global matching, so it replaces all occurences.

Sign up to request clarification or add additional context in comments.

2 Comments

regarding the global occurrences... I know that the undetermined character will always be first and always a single character. Will using g possibly interfere with other parts of this string?
@user3024007 If by "interfere" you mean change "this_is_someString_and_it_is_a_string" to "this_i_and_it_is_a_string", then yes. You could use \b to fix that.

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.