Regex: Find that words that have html, but doesn't have .dot before html.
-
hello, I need to find that words that have html, but doesn’t have .dot before html. See the lines below:
I go home now.html" and thenTake me with you nowhtml" and thenasfa asdfdsa<!DOCTYPE html><!--<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" ><html lang="en-US" xmlns:og="schema/">
The Output should be the line 2, because is contains WORD+HTML, but without .HTML:
Take me with you nowhtml" and thenI made a regex, but is not very good, because it finds all lines that doesn’t have
.HTMLSEARCH:
^(?=.*html)(?:(?!\w+\.html).)+$ -
You seem to ask a lot of regex questions.
You’d be better served by really studying regex and solving your own problems.
Likely soon this forum will quit just handing you the answers.But…
You might try
(?-s)^.*?\whtml.*, but it will match line 5 in addition to line 2. If this is not desired, you have to be more specific about what you need. -
(?-s)^.*?\whtml.*your regex is almost good, but it finds 2 lines, instead of one:
Take me with you nowhtml" and thenand
<!--<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" >THE OUTPUT must be only:
Take me with you nowhtml" and thenp.s. I ask, because my solution is not to good, and I am not an expert on regex. But as you can see, is not easy to find the solution on this problem.
-
@hellena-crainicu said in Regex: Find that words that have html, but doesn't have .dot before html.:
your regex is almost good, but it finds 2 lines, instead of one:
Yes. Did you read where I wrote?:
it will match line 5 in addition to line 2. If this is not desired, you have to be more specific about what you need
-
try this regex:
SEARCH:
(?:^|\h)\w+html"This will match your request.but, also, can be a 6 case which you missed. Suppose you have a link such as:
https://mywebsite.com/prince-is-my-fatherhtmlSo, in this case, the [dot] before
htmlis missing. But I don’t know how to handle this situation… -
ok, try this solution, very good for all your example and for the 6’ case:
SEARCH:
^(?=.*https://)(?:(?!\.html).)+$
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