Is there a way to specify regex that would match a string but from a certain position in this string? What I mean is that I have line:
"Somebodys_value is % value"
and I’d like to check if my regex matches this sentence but only after % sign.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using only RegEx you just include the % in your pattern. If your pattern is
value, you can change it to%.*value.Another way, that’s more dependent on your engine, is to provide an offset. You can use a
strposlike function to find the %, and say to start matching after that.Yet another method is to copy everything after the % into a new buffer/string, and then try to match that.
Any more specifics depend on the engine you’re using.
edit:
It sounds like you don’t want the % in your matches. A few implementation specific ways to do this are…
(?:%).*valuewhere the % is in a non-capturing group%\K.*valuewhere \K discards everything before it (limited support)%(.*value)where you will just use the first subpattern (often called $1).