abdur rahim abdur rahim - 1 month ago 8
Java Question

Finding Tin Number From String

I want to find tin number from a String of specific pattern where tin number start with with 8 or 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


I have tried that, but it returns tin numbers that doesn't start with 8 or 9

tin=(.*?)[$&]

Answer

Try with that:

tin=((?=8|9).*?)[$&]

Explanation