Extracting a word or character after a matched string excluding whiteSpace and string matching using regex

"1 cup of Greek or natural yogurt."

I want the bowl to be filtered.

"1 g of salt.

Here's where I want gm to be checked out.

I want a regex expression that is a combination of both.

Any help would be appreciated.

+3


source to share


1 answer


/^(.+?)( cup|gm)(.+?)$/i

      

replaced by



\1 \3

      

regex101

+1


source







All Articles