G
G
Grigory Knyazev2015-04-14 19:41:01
Regular Expressions
Grigory Knyazev, 2015-04-14 19:41:01

How to replace using regular expressions inside a word?

Gentlemen, the crux of the matter is as follows. There is a large text taken out of nowhere. Contains a lot of garbage, in particular, forced hyphens. They look like this: “warning”, “signal”, “thermometer”. Required: find them and remove them. A regular expression like \w-\w finds combinations "letter+hyphen+space+letter", but I don't know what to change these combinations to. You can’t just delete it, because letters will be deleted along with the hyphen-space.
upd. For complete clarity, I will give one sentence. “And the sparrow flew to its nest, looking around warily.” You need to turn it into "And the sparrow flew to its nest, looking around warily."

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petrov, 2015-04-14
@no_mad82

s = s.replace(/([\wа-яё])-([\wа-яё])/ig, '$1$2');
The "case sensitive" checkbox must be unchecked.
The "and new lines" checkbox must be checked.
Well, of course, click on the "Regular Expressions" radio button :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question