Regex MatchOffset - Does it work right ?
About this https://sm.alliedmods.net/new-api/re...ex/MatchOffset
- I'm not sure do I use it right. Should this return offset of match in string ? It now return offset of end of match in string. Below example match STEAM_ id pattern. output Code:
sm plugins reload test PHP Code:
|
Re: Regex MatchOffset - Does it work right ?
Likes a bug.
However, your double-cycle is a bit strange. Here is more clear test: PHP Code:
Quote:
|
Re: Regex MatchOffset - Does it work right ?
Quote:
https://regex101.com/r/OESJ0R/1 Using Capturing Group () |
Re: Regex MatchOffset - Does it work right ?
Yeah, but, in such case it should be rextest.MatchOffset(a) in your code, because MatchOffset is accepting index of match, not index of capture.
Index of capture can be used with GetSubString (argument str_id) as according to docs. One match can contain several captures. The capture is a part enclosed in parentheses. If you would have several enclosed parts in expression e.g. "(STEAM_)(\\d:\\d:\\d+)", so you'll have several captures in each match. Anyway, it doesn't change that the result offset is a bugged value. It should point to the start of a string index where match was found. |
Re: Regex MatchOffset - Does it work right ?
Aaa ok, I got confused with matches and captures. I need practise those again.
|
Re: Regex MatchOffset - Does it work right ?
The docs aren't the best, but it is for implementing MatchAll yourself - it gives you the offset to start searching for the next match from. It's too late to change the implementation I think.
|
Re: Regex MatchOffset - Does it work right ?
Thaw would make sense.
By reducing offset with strlen of match string, can get matching start offset. |
All times are GMT -4. The time now is 04:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.