Home > Software engineering >  Find special character # between '<' and '>' inside text
Find special character # between '<' and '>' inside text

Time:12-02

I'm stuck with finding # which is between <...> in below text:

bhdfgkkd#?gdsjkngfds/<1743610374#deliveryCustomerAck-2092288912_1638264514789@f106>

I am able to return text inside <...> 1743610374#deliveryCustomerAck-2092288912_1638264514789@f106 using regex

(?<=\<)(.*?)(?=\>)

but how to return only #?

PS I will use this regex in Java

Update: done, answer below. Thx for help.

CodePudding user response:

You are almost correct. Wrap the # inside a group so that you can retrieve it later with group number 1 in your language of choice.

(?<=\<).*?(#).*?(?=\>)

DEMO

  • Related