Reputation: 664
Here is the text.
H:46" W:22.75" D:24.5"
Inside: W:15.5" D:17"
COM Requirements: 3 yds
COL Requirements: 54 sq ft
Also Available: 73-26 26" Seat Height
I need to find out width for the first occurrence in the first line. I want width 22.75
.
I also try out with regex.com
Here i find out two occurrences for width
now I use W:(\d+\.?\d*)\1
for the first occurrence but i can't find it out.
Upvotes: 0
Views: 68
Reputation: 1265
use from lookbehind
and lookahead
:
/(?<=W:)(\d+\.?\d*)(?=")/g
To be more precise and to avoid errors, it is best to specify the pattern before and after. test: Link
Upvotes: 0
Reputation: 7780
Drop the global (g
) flag and it will only return the first match. i.e. /W:(\d+\.?\d*)/
instead of /W:(\d+\.?\d*)/g
Upvotes: 1