Skip to main content
Question

How do I extract multiple substrings from text

  • January 12, 2022
  • 2 replies
  • 86 views

I have the following string:

 

mapMarkers.push(bap(map,'','marker.php/oaaa/BusShelter:BusShelter:BusShelter/EB:WB:EB/1/null/null/39.69643098429845/-104.88185718655586/null','','interactive_view:f=D0007.1.1.1|f=D0007.1.2.1|f=D0007.1.3.1',1, null, null, 1, null, null, ["BusShelter"], true));

 

I'd like to extract the lat/long values as well as any values following f=

 

So for the example above, I should get the following attributes:

 

Lat=39.69643098429845

Long = -104.88185718655586

ID1 = D0007.1.1.1

ID2 = D0007.1.2.1

ID3 = D0007.1.3.1

 

Do I use a stringsearcher with a regex? If so, how?

2 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • January 12, 2022

For the lat/long, I would use an AttributeSplitter with '/' as the delimiter. Your Lat would be _list{7} and your Long would be _list{8} in this example.

 

For the IDs, I would use the StringSearcher with the regex f=.{11} . Under the Advanced section, give the parameter All Matches List Name a value. You can then use the AttributeCreator to create the ID attributes from these list values, and finally the StringReplacer to remove f= from the ID attributes.


takashi
Celebrity
  • 7842 replies
  • January 13, 2022

For the lat/long, I would use an AttributeSplitter with '/' as the delimiter. Your Lat would be _list{7} and your Long would be _list{8} in this example.

 

For the IDs, I would use the StringSearcher with the regex f=.{11} . Under the Advanced section, give the parameter All Matches List Name a value. You can then use the AttributeCreator to create the ID attributes from these list values, and finally the StringReplacer to remove f= from the ID attributes.

Hi @Mario Federis​ , I agree that the AttributeSplitter would be an easy way to extract latitude and longitude.

There could be various ways to extract IDs. For example, the StringSearcher with these parameter settings extracts all the IDs from the string and save them into a list called "_id{}.match".

  • Contains Regular Expression: (?<=f=).\\d+\\.\\d\\.\\d\\.\\d
  • All Matches List Name: _id