Regular expression to match "="
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bruno Luong
am 21 Sep. 2019
Kommentiert: Bruno Luong
am 21 Sep. 2019
In try to find a simple pattern p to match a single '=' but ignore '==' in a string
So I want
regexp('a = b', p)
to return 3
regexp('a == b', p)
to return [].
I try several things and they are all fail on '=='
>> regexp('a == b','=(?!=)')
ans =
4
>> regexp('a == b','={1}')
ans =
3 4
>> regexp('a == b','(?!==)=')
ans =
4
Any suggestion for simple pattern?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Sep. 2019
regexp('a == b = d','(?<!=)=(?!=)')
This looks for = that are not preceded by = and not followed by =
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!