Skip to content
Advertisement

Tag: extract

Advice on how to resolve an issue with extracting only numbers from a string using JavaScript

I’m new to stackoverflow and would appreciate some advice to help me solve this problem. I have two strings that I want to extract numbers from String 1 = “12.3,Name1,3,4,Name2,35,Name3” returns [12.3,3,4,35] Which is the required result. String 2 = “12.3,22,Q” returns [12.322] Which is the incorrect result, It should be [12.3,22] I have commented on my code with the

Whats wrong with this regex to remove substring?

Trying to strip out the extra addressee from an address string. In the example below, dba bobs is the targeted string to remove. The above yields: When the desired is: What am I doing wrong? Sometimes the input has a ‘n’ before the ‘dba’. Answer You can simplify your regex to: /b(attn|co|dba|fka|dept)b.*/gm Test here: https://regex101.com/r/TOH9VV/2 EDIT: Included suggestion of user

Advertisement