Question

How do I extract multiple substrings from text

  • 12 January 2022
  • 2 replies
  • 10 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

Userlevel 3
Badge +26

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.

Userlevel 2
Badge +17

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

 

Reply