Marc Ortiz
Marc Ortiz

Reputation: 2412

Replace character and words

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!

Upvotes: 1

Views: 68

Answers (1)

David Thomas
David Thomas

Reputation: 253396

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, '');

Upvotes: 2

Related Questions