Mahx Michael
2/2 Zombie
Recently Ressurected
Posts: 100
Favorite Card: Divine Visitation
Color Alignment: White, Blue, Green
|
Post by Mahx Michael on Oct 10, 2018 15:56:59 GMT
According to the regex manual, . means any item except lineshift, and .* means any number of . So in other words, the following regex should only match if there are no lineshifts in between:
<color:red>\".*(<sym-auto>|<sym>).*<match>.*(</sym-auto>|</sym>).*\"</color>
Somehow, this isn't the case, and the script starts disturbing other lines, that should not match this expression.
Does anyone know why this is and/or a way to get around it?
Edit: Also, aparently, MSE dislikes that I use [^\n] in regex. How can I work around that? Edit: If i try to replace . witg [^\n] , should i use [^\n]* or [^\n]+ then?
|
|
Mahx Michael
2/2 Zombie
Recently Ressurected
Posts: 100
Favorite Card: Divine Visitation
Color Alignment: White, Blue, Green
|
Post by Mahx Michael on Oct 10, 2018 17:57:12 GMT
If I try with
<color:red>\"[^\"]*(<sym-auto>|<sym>)[^(<sym-auto>|<sym>)]*<match>[^(</sym-auto>|</sym>)]*(</sym-auto>|</sym>)[^\"]*\"</color> It seems like it should work, but whenever i put (<sym-auto>) in negate like this [^(<sym-auto>)] , it seems regex reads it as a range, and I get an error. A normal \ escape doesn't seem to work, so how do I do this?
|
|
|
Post by cajun on Oct 10, 2018 18:16:34 GMT
For the first, think you need
[^\\n]
if it's possible to match no linebreak characters (ie this can match the end of a line) use *, otherwise + is fine.
Negated non-characters use a bit different syntax
(?<!words) ##Doesn't match if "words" is before the matched regex (?!words) ##Doesn't match if "words" is after the matched reged
regex = (?<!words)apple(?!words) apple ## matched, "apple" wordsapple ## not matched applewords ## not matched appleword ## matched, "apple" apple words ## matched, "apple"
|
|
Mahx Michael
2/2 Zombie
Recently Ressurected
Posts: 100
Favorite Card: Divine Visitation
Color Alignment: White, Blue, Green
|
Post by Mahx Michael on Oct 10, 2018 18:26:58 GMT
So the main problem is that if i write something like <tag>.*<match>.*</tag> , regex will read everything between <tag> and line break as .* (or something like that), and the expression won't be what I intended it to. Is there a way to put a "wildcard" with an "until" statement, that sais do(.*).until_hits(</tag>) I'm not sure if the last thing I wrote made any sense to you, but is there a way formulate the breaking of a wildcard pattern? Edit: How will this work? regex = (?<words)apple(?words) and this: regex = (?<words).*apple.*(?words) and this: regex = (words)(?<!words).*apple.*(?!words)(words) And if I'm working with tags, do i write them (?<!\<tag>), then?
|
|