Skip to main content
Mar 3, 2020 9:46 AM UTC
Solved

Splitting or matching a string in a service

Hi,

I want to take a part of input string and compare it with an existing string and store it. There are functions like split, splice , includes, etc in JS but I am unable to use them. How can I achieve the functionality?

Mar 4, 2020 9:22 AM UTC

Those two lines are equivalent to the code snippet that you provided in your previous message, just shorter.

8 replies

Mar 3, 2020 10:50 AM UTC

Hi,

 

You can use substring:

var str = "This contains a string.";
var cut = str.substring(2,11); // cut = "is contai"

 

Mar 4, 2020 5:02 AM UTC

Just checked it, can you tell me why it isn't working in the infotable for loop? outside the loop it works fine! The thing is, I am comparing the string with another string which is in the infotable

Mar 4, 2020 7:49 AM UTC

@gourinaik98, can you show an example of your code where it doesn't work?