Reputation: 149
I am new to regex still in learning phase. I wrote an regex expression to extract until first occurrence of a colon:
^([^:]+):
Now I want to take it one step further and limit the search to within first 100 characters. Which mean no match if match does not occur within first 100 characters and I don't know how to amend this expression to do the needful.
Upvotes: 1
Views: 1304
Reputation: 8711
Check this
(?!^[^:]{100})(^[^:]+):$
https://regex101.com/r/dBOzVT/2
Upvotes: 0
Reputation: 3627
Try this:
^([^:]{1,100}):
This regex matches all text from the start of line/text to the first colon only if there is 1–100 characters before the colon ({1,100}
instead of +
).
Upvotes: 3