Home > Blockchain >  Regex Expression between two string
Regex Expression between two string

Time:12-09

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

  • Related