-1

I have tried numerous regexs in an attempt to solve this issue but I cannot solve it. As the title suggests I am tempting to extract everything in a string except for a keyword that I know will/could be located in the string. I am using https://regex101.com/ to test my regex's. The sample strings are below.

"Job Care Worker"
"+jobs +Nurse"
"construction worker"

I've tried using a negative lookahead such as ^((?![jJ]ob).)*$ but if I plug this into https://regex101.com/, with my test strings, I am unable to remove the word Job. That is essentially my end goal here, remove the word jobs from the string.

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

2

Simply take everythign except "job".

Select (.*)job(.*) and replace it with group 1 and 2 ($1$2)

you need the case-insensitive-flag here (/i)

See https://regex101.com/r/hRFNUe/1

Chrᴉz remembers Monica
  • 1,829
  • 1
  • 10
  • 24
  • Thanks for the answer Chriz, This works on the website which is awesome, but I actually need to embed this regex into a javascript for a UDF in BigQuery. Can JS do substitutions? – Jared Rieger Jun 05 '18 at 09:04
  • @JaredRieger for information on how to execute the regex in JS and how to acces groups, see [here](https://stackoverflow.com/questions/432493/how-do-you-access-the-matched-groups-in-a-javascript-regular-expression) . You'd need match 1 and 2 here, match 0 is the whole matched regex – Chrᴉz remembers Monica Jun 05 '18 at 09:11