const string = "(https://test.blob.core.windows.net/raw/DET_IM_3TM5_]Systems_Manual.pdf?st=2024-03-08T17:02:24Z&se=2138-04-07T09:02:24Z&sp=r&spr=https&sv=2023-11-03&sr=b&sig=MRCMS0OCPSBc1NhAjIPE%3D) - [491](https://test.blob.core.windows.net/raw/DET_IM_3TM5_Manual.pdf?st=2024-03-08T17:02:24Z&de=2138-04-07T09:02:24Z&sp=r&spr=https&sv=2023-11-03&sr=b&sig=MRXa1O9AxHW8IPE%3D#page=491)(https://sa003stdirtest.blob.core.windows.net/raw/DET_IM_3TM5_]Systems_Manual.pdf?st=2024-03-08T17:02:24Z&se=2138-04-07T09:02:24Z&sp=r&spr=https&sv=2023-11-03&sr=b&sig=MRCMS0OCcIPE%3D) - [492](https://ditest.blob.core.windows.net/raw/DET_IM_3TM5.pdf?st=2024-03-08T17:02:24Z&se=2138-04-07T09:02:24Z&sp=r&spr=https&sv=2023-11-03&sr=b&sig=MRCMS0OCD#page=492)";
const regex = /(?:https?|ftp):\/\/[\n\S]+?(?=\s|$|\)|\()|www\.[\n\S]+?(?=\s|$|\)|\()|\[\d+\]\((.*?)\)/gi;
// Array to store matched URLs
const urls = [];
// Match URLs and push them to the array
let match;
while ((match = regex.exec(string)) !== null) {
// Extract only the URLs contained within [number](url) pattern
if (match[1]) {
urls.push(match[1]);
}
}
console.log(urls);
Replace string variable by your string attribute.
You can use above code in javascript action.
Hope this will work.
This case can use java action to split it into a entity list. for example URL entity list then the input to java action should be String . After found the url in string add to the list and then commit.
Code:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//Begin
IContext context = this.getContext();
String inputText = this.InputText; // Assume InputText is the parameter name for input text
// Regex to find URLs
Pattern pattern = Pattern.compile("https:\\/\\/[^\s]+");
Matcher matcher = pattern.matcher(inputText);
while (matcher.find()) {
String foundUrl = matcher.group();
// Create new URL object and set its attribute
URL urlObject = new URL(context);
urlObject.setUrlString(foundUrl);
Core.commit(context, urlObject);
}
return null;
//End
Hey!
Substring and find functions should also work
something like find($string,'https',1) --> meaning first occurance
then store this number in a variable
find ($string,')') store in another variable
and substring($string,$var1,$var2) should work
Here is a way to do this using Mendix capabilities only
Running this microflow displays the following in the Console: