-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture function only returns one match #342
Comments
You make an assumption that the function How is JSLT supposed to know that more than 1 URL appears in the text ? Instead, it only finds at most 1 occurence. Currently you have to structure your {
"body": [
"<div class='intercom-container'><img src='https://downloads.intercomcdn.com/i/o/243069600/b5cf534d3975fafc7eafa9e7/IMG_2568.PNG?expires=1671464976&signature=6dc0e026cb490829b7e333f8254dd50358356f9bf3369339ddb3aaf11d14ca34'></div>",
"<div class='intercom-container'><img src='https://downloads.intercomcdn.com/i/o/24306960011/b5cf534d3975fafc7eafa9e7/IMG_2568.PNG?expires=1671464976&signature=6dc0e026cb490829b7e333f8254dd50358356f9bf3369339ddb3aaf11d14ca34'></div>"
]
} The JSLT transformation then is
resulting in: [ {
"url" : "https://downloads.intercomcdn.com/i/o/243069600/b5cf534d3975fafc7eafa9e7/IMG_2568.PNG?expires=1671464976&signature=6dc0e026cb490829b7e333f8254dd50358356f9bf3369339ddb3aaf11d14ca34"
}, {
"url" : "https://downloads.intercomcdn.com/i/o/24306960011/b5cf534d3975fafc7eafa9e7/IMG_2568.PNG?expires=1671464976&signature=6dc0e026cb490829b7e333f8254dd50358356f9bf3369339ddb3aaf11d14ca34"
} ] |
I don't think this is the right way to view the issue. The issue being raised is:
And clearly there has to be a way to do that. We can't require people to structure the input in a way that fits JSLT. The language has to be designed to handle all JSON inputs. It is possible to do this now by using One way to solve it would be to give |
I see your points, regarding Until we have a Whether implementing a recursive function, or restructuring the input, neither is elegant. Not knowing a lot about the original use case, if the developer is capable of chunking some source HTML into a JSON object carrying a |
Found another solution, without having to change the input:
|
this solution worked! thanks. |
i do think having a |
Try this one:
It supports all kinds of URLs. |
I'm trying to get all the
img src
URLs from an HTML body in one of the json fields:{ "body" : "<div class=\"intercom-container\"><img src=\"https://downloads.intercomcdn.com/i/o/243069600/b5cf534d3975fafc7eafa9e7/IMG_2568.PNG?expires=1671464976&signature=6dc0e026cb490829b7e333f8254dd50358356f9bf3369339ddb3aaf11d14ca34\"></div>. <div class=\"intercom-container\"><img src=\"https://downloads.intercomcdn.com/i/o/24306960011/b5cf534d3975fafc7eafa9e7/IMG_2568.PNG?expires=1671464976&signature=6dc0e026cb490829b7e333f8254dd50358356f9bf3369339ddb3aaf11d14ca34\"></div>" }
If I do the following JSLT code
capture($node.body, "<img src=\"(?<url>https://[^\"]+)\">")
I will get just the first img URL but not the second.There should be a way to return all matches...
The text was updated successfully, but these errors were encountered: