Here are the example of input and output
Example input: SSS1111 Output: SSS-1111
Example input: SS111 Output: SS-111
Assuming strings consist of one or more letters (A-Z) followed by one or more numbers (0-9):
var before = 'SSS1111'
var after = s.replace( /([a-z])(\d)/i, '$1-$2' )
The regexp matches matches any letter [a-z]
followed by any digit \d
and replaces it with the letter, followed by a dash, followed by the digit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With