I have the following content :
hi
first young CEO's TEST-TEXT
hello
I am trying to match the TEST-TEXT string to replace it is value but only when it is a text and not within an attribute value.
I have checked the concepts of look-ahead and look-behind in Regex but the current issue with that is that it needs to use a fixed width for the match here is a link regex-match-all-characters-between-two-html-tags that show case a very similar case but with an exception that there is a span with a class to create a match
also checked the link regex-match-attribute-in-a-html-code
here are two regular expressions I am trying with :
- \"([^"]*)\"
- (?s)(?<=<([^{]*)>)(.+?)(?=)
both are not working for me try using [https://regex101.com/r/ApbUEW/2]
I expect it to match only the string when it is a text
current behavior it matches both cases
Edit : I want the text to be dynamic and not specific to TEST-TEXT
Answer
A RegEx for that a string between any two HTML tags
(?![^<>]*>)(TEST\-TEXT)
No comments:
Post a Comment