简体   繁体   中英

Javascript complex REGEX

I have some definition that come in a similar appearance: "(adj.) currently holding office (eg the ..... president had been defeated) " I need to split them in this way:

var fullDefinition= " (adj.) currently holding office"
 var definition="currently holding office"
 var word = "....."
 var example = " the " + word + "president had been 
 defeated"

The elements in common for every definition, which I can use as anchors, are the two brackets " ( )" but not the content inside the dots " ..... " the string " (eg " with the last bracket " )" I am newbie, I think I need to use regular expression here, but I don't know how

This site is great for trying out regular expressions. You can create an account and save the regular expressions.

https://regex101.com/r/I7DFWb/1

Here are some resources to read up on to get an idea of the formats to use.

https://www.w3schools.com/jsref/jsref_obj_regexp.asp

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

RegEx are very cool to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM