so I have been tring to figure out the if function in regex but, can get in the hang of it.
These are the two scenarios that can happen:
- - [MyTag] Random text that can have 0-9 with special case.
- - Random text that can have 0-9 with special case.
what my pattern should do:
IF (text contains "]") THEN start from "] " ELSE start from " - "
I have attempted to reach that with this: (?(\] )(\].*$)|(\-.*$))
and of course failed. We got the
(\].*$) which collets the part from "] " until END OF LINE has been reached
(\-.*$) collects from "- " until END OF LINE
?(\] ) Which should act as the IF statement
so can someone explain to me what is wrong and how to fix it?
], use[-\]].*.