Extract an ISBN with regex

后端 未结 7 1876
终归单人心
终归单人心 2021-01-14 01:01

I have an extremely long string that I want to parse for a numeric value that occurs after the substring \"ISBN\". However, this grouping of 13 digits can be arranged differ

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 01:06

    You can strip out the dashes with string manipulation, or you could use this:

    "\\b(?:\\d-?){13}\\b"
    

    It has the added bonus of making sure the string doesn't start or end with -.

提交回复
热议问题