problem with this regex: \b.{1,6}\b
-
I made a simple regex “\b.{1,6}\b” that matches every word contains less than 7 charecters,
And yes it works, But the problem that it’s matching this type of words: “ab!cdefghi”, while it contains 10 charecters… maybe because it contains “!” symbol.
so is there any way to make a regex that don’t match words contains +6 charecters even it contains a symbol like “!” -
@Bahaa0013
(?<!\S)\S{1,6}(?!\S)abdc! #$#$@ $##@ ~~~NO & *( #R%$%$%# abcdefgMy regex will mark only first six lines, not last two.
Note that I chose the negative assertions “not not a whitespace before or after” (
(?<!\S)and(?!\S)) because that assertion matches at the beginning and end of the file, and the alternative “must be a whitespace” ((?<=\s)and(?=\s)) do not. -
Nice point about matching at start/end of file.
-
Hello, @mark-olson,
Indeed, I would not have thought of that. As always, it is the borderline cases that need to be studied !
Best Regards,
guy038
-
@Mark-Olson
Thank you very much, it worked very well…
Also thanks to everyone who tried to help.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login