我想从特定模式的字符串中找到锡号,其中锡号以8或9开头

input:
sample1="passport=11231&tin=91312312313&dl=12313"
sample2="tin=81312312314&dl=12313&passport=11231"
sample3="dl=12313&passport=11231&tin=71312312313"

Expected output:
91312312313
81312312314
false

Current output:
91312312313
81312312314
71312312313


我已经尝试过了,但是它返回的锡数不是以8或9开头

tin=(.*?)[$&]


编辑:请注意,锡号也可以包含a-zA-Z,但始终以数字开头

最佳答案

简单的东西怎么样

tin=[89]\d*


如果您想将此号码分组使用

tin=([89]\d*)


如果value不需要仅保留数字,则可以使用\d甚至[^&$]代替[^&],因为在您的示例中看不到任何$

tin=([89][^&$]*)

08-26 20:47