How to use split function in SSJS to split String?  In my case, I have given the String and , the way I want to split is as follows : My String : I want 2 splits dfc_1 : dfc_ and 1 dfc_45932 : dfc_ and 45932


It should be as simple as:

var parts = source.split(/(?<=_)/);

Where /.../ is a regular expression, (?<=...) is a look-behind, and _ is the thing you're trying to split after.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.