I need to help for Regex expression characters between two string. If not found second character output will be all sentence after first character.
First character = "-p-" Second character = "?"
-p-sentence? => output = sentence
-p-sentence => output = sentence.
Could anyone help me with this?
CodePudding user response:
With this regex, you can get result with group 1:
-p-(.*?)(?:\?|$)
See result here