GAS Help with regex.exec()

I’m working on a script to cut down some imported text using a RegEx to find an ending point.

I’ve gotten to the point where I can run my script and I can see the item that I need - but I have no idea how to access this info.

I’ve got a regex.exec() that runs…
3X_d_c_dc944e01cb0a09a856219068f32b43b4fbc1d913.png

How do I access this part?

3X_8_0_8026f1e80b8bab315e031ad9d5d4c3bb66d38890.png

I have tried:

var endPoint = regex.exec(body).index;

  • but that doesn’t work - I get an error.

Thanks so much! 3X_d_6_d69f202e8d434fc9687f315afb983b8204d94feb.gif

Solved Solved
0 8 268
1 ACCEPTED SOLUTION

I think I figured it out.

I was trying to do it all in one shot, as in:

var endPoint = regex.exec(body).index;

The system doesn’t like that, but if you split it up into two parts it works:

var regExRun = regex.exec(body);
var endPoint = regExRun.index;

I’m the type to reduce things to it’s simplest terms if possible; seems that bit me in the ass this time.

View solution in original post

8 REPLIES 8
Top Labels in this Space