Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex RegExp to Java RegExp
    text
    copied!<p>Recently i was looking for help to extract some pattern of a URL using RegExp in flex, Few guys kindly helped me to get it done. <a href="https://stackoverflow.com/questions/7358756/how-to-extract-specific-parts-of-a-url-and-replace-with-different-data">See this</a> I need to do it again in java layer, i tried to applied the same regExp pattern in java, but it gives me an error.</p> <pre><code>var s:String = "www.something.com@param1={{^User Name^}},{{^,e,^}},param2={{^user id^}}"; var userPattern:RegExp = /(?&lt;=param1=)({{\^)([A-Za-z0-9\^}}{{, ])*(})/; var userIdPattern:RegExp = /(?&lt;=param2=)({{\^)([A-Za-z0-9\^}}{{, ])*(})/; s = s.replace(userPattern,'username'); s = s.replace(userIdPattern,'user_id'); </code></pre> <p>This gives the www.something.com@param1=username,param2=user_id.</p> <p>Can somebody help me out to do this in java layer, relavent regular expression is enough.</p> <p>This is what i tried in java,</p> <pre><code>String url = "http://www.google.com/@param1={{^Case Name^}},param2={{^Case Id^}}"; String urlPattern = "/({{\\^)([A-Za-z0-9_\\^}}{{, ])*(})/"; Pattern paramPattern = Pattern.compile(urlPattern); Matcher matcher = paramPattern.matcher(url); System.out.println("Matches - "+matcher.matches()); System.out.println("Find - "+matcher.find()); </code></pre> <p>It gives this error</p> <blockquote> <p>Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition near index 1 /({{\^)([A-Za-z0-9_\^}}{{, ])*(})/</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload