javaregex

Finding fields in String java regular expression


I am not good at Java regular expressions.

I have following text

[[image:testimage.png||height=\"481\" width=\"816\"]]

I want to extract image: , height and width from above text. Could someone help me writing regular expression to achieve it ?


Solution

  • Try this regex:

    ((?:image|height|width)\D+?([a-zA-Z\d\.\\"]+))
    

    You will get two groups.

    e.g.,

    1. height=\"481\"
    2. 481