Skip to content
Advertisement

Re Regular expression operations, remove periods?

I’m working with a function I made to split this sample line below to remove the standalone numerical values (123), however it’s also removing the trailing numbers which I need. I also can’t figure out how to remove the “0.0”

ABC/0.0/123/TT1/1TT//

JavaScript

What’s coming out now is below, notice the 0. and “TT” that’s missing the trailing 1.

[ABC], [0.], [TT], [1TT]

Advertisement

Answer

Try including the start of line anchor (^) as well.

JavaScript

I simply changed the default value of the remove parameter to ‘^[0-9.]+$’ which only matches if the entire search string is numbers (or a period).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement