Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How can I turn this "- | " into "-" with jQuery?
.replace(/__-__ | /g, '__-__'
This also replaces the empty spaces
.replace('__-__ | ', '__-__'
This only replaces the first time it occurs
.replace()
Not sure why you're attempting this in jQuery. String replace is a javascript string method unless you're talking about replacing DOM elements.
input.replace(/- \|/g, '-_-');
See this example.
Add a comment
You answer helpt me out! :)
.replace(/__-__ \|/g, '__-__')
This worked just great! Thanx!
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
.replace()is plain javascript? The first one uses a global regex, and the second one just matches the first occurence in a string.