Skip to main content
1-Visitor
March 3, 2020
Solved

Splitting or matching a string in a service

  • March 3, 2020
  • 8 replies
  • 4657 views

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?

Best answer by Constantine

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

8 replies

15-Moonstone
March 3, 2020

Hi,

 

You can use substring:

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

 

1-Visitor
March 4, 2020

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

18-Opal
March 4, 2020

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