Skip to content

Instantly share code, notes, and snippets.

@sandeep1995
Created June 20, 2017 21:08
Show Gist options
  • Save sandeep1995/dd294bdec416ce0b556d2996fd7a77b0 to your computer and use it in GitHub Desktop.
Save sandeep1995/dd294bdec416ce0b556d2996fd7a77b0 to your computer and use it in GitHub Desktop.
Find all the matches of xlink:href="<---I NEED THIS --->" from one SVG String
public void findEmbeddedImages() {
Pattern pattern = Pattern.compile("([^[-\\\\w.]+$\\/\\:\\.]*\\.(jpg|jpeg|png|gif))", Pattern.CASE_INSENSITIVE);
// Pattern pattern = Pattern.compile("xlink:href=\"[^\"]*\"", Pattern.CASE_INSENSITIVE);
Matcher matches = pattern.matcher(this.svg);
while (matches.find()) {
System.out.println("Match Found: " + matches.group());
this.links.add(matches.group());
}
}
@sandeep1995
Copy link
Author

def find_embedded_image
    @svg.scan(/([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif))/i) { |res|
      @links.add(res[0])
    }
   return @links.size
end

I am using the above code in my ruby application. This RegEx does work in the Ruby application. But I can not get it work in Java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment