user1384205 user1384205 - 3 months ago 9
Scala Question

Regex to match number after a defined text

I have the following text to apply regex on, where I want to replace all occurences of ,N, to be replaced by ""


I was able to test this regex (,N,[\d]) in . The expression seems to correctly match the text.

However when I use it on my program, the regex does not work

val regN = """(,N,[\d])"""

.map (row => row.replace(regN, ""))

The end result im looking for is this

What am I doing wrong?


String.replace this method will not replace by regex: String.replace

you should use String.replaceFirst or String.replaceAll:String.replaceFirst String.replaceApp