Example: ABCD, NC exg. 58/2095, s.2.7 A. 2A.
ABCD, NC exg. 58/2095, s.2.7 A. 2A.
is the text and am using Regexp
`String.replace(/([az]+).|.([ ?!\\d])/ig, '$1')
O/p : Missing some Text from the Text.
Expected is:
ABCD, NC exg 58/2095, s.2.7 A2A
--dot followed by non digit(special Char or Alphabets) should replace with null.
You can use alternation and grouping.
([az]+)\\.
- Matches one or more character (captures as group) followed by dot.
\\.([az]+)
- Matches dot followed by one or more character (captures chracters as group)
And in replace by the matched group.
let str = `ABCD, NC exg. 58/2095, s. 2.7 ` let op = str.replace(/([az]+)\\.|\\.([az]+)/ig, '$1') console.log(op)
If your input is only ASCII, just replace every letter followed by a dot with the character itself:
console.log( "ABCD, NC exg. 58/2095, s. 2.7".replace(/([az])\\./ig, '$1') );
Removing every special character.
Because that's what you are telling it to do. [^\\w.\\s]
matches every character that is not a letter, number, _
, .
or white space.
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.