Extract a string with JavaScript

I need a JavaScript version of @left and @right.This example generates “abc” from a string of “abcdefg”:

the slice() function in JS does only take numeric values to calculate. Instead I want to search the string with two text values like this to get the letters between abc and fgh:

This example does not work of course, but you can see what I am looking for.

Does anybody know what method I can use ?

Subject: extract a string with JavaScript

The easy way is to use split

origstring=“abcdef”

newarray=origstring.split(“de”)

newstring=newarreay[0]

Chris Boote

Subject: extract a string with JavaScript

Here are some thoughts…

  1. MyString.indexOf(searchString) returns the position of SearchString in MyString

  2. MyString.length returns the length of MyString

  3. MyString.slice(P1,P2) returns a piece of MyString

If your funtion is for exampe …

getPart(SourceString, SearchString1, SearchString1)

Your get

P1 = SourceString.indexof(SearchString1)+SearcHString.length

and P2=SourceString.indexof(SearchString2)

and

SourceString.slice(P1,P2) should return what you want.

hope it helps

UnTo