1

How can I replace characters to get a text only with words?

Here's the code:

text.replace('/', '');

ley orgánica 4/2013 28 junio reforma consejo general poder judicial modifica ley orgánica 6/1985 1 julio poder judicial

From this text I would like to replace 4/2013 to '' and 6/1985 and the numbers 28 and 1. Thanks!

1
  • ok so you want to wipe out 4/2013... but what are you wanting for the second date numbers? Commented Jul 10, 2013 at 20:18

1 Answer 1

2

I'd suggest, in this limited case:

var text = 'ley orgánica 4/2013 28 junio reforma consejo general poder judicial modifica ley orgánica 6/1985 1 julio poder judicial',
    newText = text.replace(/([\/0-9])/g, '');
Sign up to request clarification or add additional context in comments.

2 Comments

@MarcOrtiz you should give more information then just "still not working"
@MarcOrtiz Don't forget that replace, doesn't modify original string. It returns new string with replaced matches.

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.