Home > Enterprise >  How to exclude some word in string in regex (to replace using javascript)
How to exclude some word in string in regex (to replace using javascript)

Time:09-21

I want to select word between two (") and exclude other word outside (") to replace string using javascript replace. This is my string

The receptionist: "Okay, please wait a moment." After a while, the receptionist smiled and said, "Congratulations, you have obtained a certificate of exemption from the exam for job transfer. With it, you can use it after you reach a certain Level. After completing the job transfer task, you can directly transfer to a specific occupation, a very convenient little gift."

I want to select "Okay, please wait a moment." and "Congratulations, you have obtained a certificate of exemption from the exam for job transfer. With it, you can use it after you reach a certain Level. After completing the job transfer task, you can directly transfer to a specific occupation, a very convenient little gift." and exclude other.

I try /". "/g and it include all from "okay to gift." and not exclude other Please help me and thank you

CodePudding user response:

I Think its could works: /("[^"] ")/g

This regexp match any group of words that have an initial ", one or more characters different to " and finally ends with a " You can see it in this result of the regex

  • Related