Reputation: 65
I have been trying to make a regex to match the text after settings.
in the following string
GPIO.setup(settings.pic_taken_led , GPIO.OUT, initial=GPIO.LOW)
IE (pic_taken_led
)
I have so far come up with /(?<=settings)([.]\w+)/g
but it matches with the period and I need it without the period. (.pic_taken_led
).
I feel I am close but I can't remove the period from the capture expression.
Upvotes: 1
Views: 491
Reputation: 626870
You can use
(?<=settings\.)\w+
^^^^^^^^^^^^^^^
See the regex demo.
Details
(?<=settings\.)
- a positive lookbehind that matches a location immediately preceded with settings.
string\w+
- one or more letters, digits, _
s.VSCode demo:
Upvotes: 2
Reputation: 2892
You are really close. Since you want to capture pic_taken_led
, just capture the String after .
So your regex should be (?<=settings).(\w+)
Upvotes: 0