How about
/(^|\s)(Sec\.|Sections?) +[0-9]+(\.[0-9]+)*( +and +[0-9]+(\.[0-9]+)*)*(?=$|\s)/
It will match substrings that
- begin with whitespace or are at the beginning of the searched string
- are followed by whitespace or are at the end of the searched string
- start with
Sec., Section or Sections
- followed by one or more spaces
- followed by a section number
- optionally followed by one or more
and [section number], where and is surrounded by one or more spaces.
Section numbers match if they
- start with one or more digits
- optionally followed one or more times by a dot and again one or more digits.
You can trim the match to get rid of eventual whitespace at the beginning of the match.
Update
/(^|[^\w])(Sec\.|Sections?) +[0-9]+(\.[0-9]+)*( +and +[0-9]+(\.[0-9]+)*)*(?=$|[^\w])/
This one matches substrings that
- begin with a non-word character or are at the beginning of the searched string
- are followed by a non-word character or are at the end of the searched string
Rest same as above. Use an additional replace on the match to get rid of non-word character matches at the beginning: match.replace(/^[^\w]+/, '')
"Sect 666"be matched for example ?