I have a text where I need to capture the second group
Response on your Property Listing
Dear Rahul Bond,
A user is interested in your Property, ID 62455995: 2 BHK , Multistorey
Apartment in Raheja Vihar , Mumbai.
Details of Contact Made:
Sender's Name: Test (Individual)
The text to be retrieved is 2 BHK , Multistorey Apartment in Raheja Vihar , Mumbai. This does start with **A user is interested in your Property, ID xxxxxxx: **
A user is interested in your Property, ID 62455995: 2 BHK , Multistorey
Apartment in Raheja Vihar , Mumbai.
The expected output is 2 BHK , Multistorey Apartment in Raheja Vihar , Mumbai.
I have tried with .match(/(A user is interested in your Property, ID.*[^:]) (.*\n.*)/g)
Unfortunetly it gives me all 2 lined text.
You can use this regex:
const text = `Response on your Property Listing
Dear Rahul Bond,
A user is interested in your Property, ID 62455995: 2 BHK , Multistorey
Apartment in Raheja Vihar , Mumbai.
Details of Contact Made:
Sender's Name: Test (Individual)`;
const rgx = /(?<=A user is interested in your Property, ID \d+: )(.*\n.*)/g;
const result = text.match(rgx);
console.log(result);
It works here https://regexr.com/6tulh