Muqri
Muqri

Reputation: 69

Regex capture number before specific word Google Script

I need to capture phone number before specific word "Congratulations"?

Here an example:

Billing address
Houston
77990
013XXXXXXX

Congratulations on your purchase.

Regex:

013XXXXXXX

Code:

(\w+)(?=\s+Congratulations)

(.+)(?=\s+Congratulations)

(\d+)(?=\s+C)

I use this three regular expression but google script does not return anything while in regex101.com its work just fine

Is it because lookahead cannot be used in google appscript?

Upvotes: 0

Views: 294

Answers (1)

Cooper
Cooper

Reputation: 64040

var re=/^[\(\) 0-9-]{6,}$/m;
var matchA=s.match(re);

string match method

Upvotes: 2

Related Questions