DhanaMerdeka
DhanaMerdeka

Reputation: 1

Can I get 2 separate word on one regex?

Sample text:

Code= go to 65416541654 name DHANA for 1 period JUL 2021 SN Hrg=314800 Bill=313500 Admin=2500 Total Bill=316000 check Bill SUCCESS. Balance=835606.

I need to extract Name DHANA and Total Bill=316000. Could I do that using single regex?

My regex now is

/(name)( | :|:|=| =)(?P<sn>(.*?))(check bill)/i

But with this regex I capture other things that I didn't even need.

DHANA for 1 period JUL 2021 SN Hrg=314800 Bill=313500 Admin=2500 Total Bill=316000

So can I just capture only NAME and the Total Bill alone without period and anything between?

More info
- The name can be more than one word Example Dhana Merdeka
- if possible i need the captured SN will show DHANA MERDEKA Total Bill=316000 or DHANA Total Bill=316000 (if the name only one word)

Upvotes: 0

Views: 66

Answers (0)

Related Questions