English 中文(简体)
Java RegExp
原标题:Flex RegExp to Java RegExp

最近,我正在寻求帮助,以灵活的方式利用Refp,帮助我获得这种支持。 见。 我需要在java层再次这样做,即在java尝试采用同样的排外模式,但给我留下了一个错误。

var s:String = "www.something.com@param1={{^User Name^}},{{^,e,^}},param2={{^user id^}}";
var userPattern:RegExp = /(?<=param1=)({{^)([A-Za-z0-9^}}{{, ])*(})/;
var userIdPattern:RegExp = /(?<=param2=)({{^)([A-Za-z0-9^}}{{, ])*(})/;
s = s.replace(userPattern, username );
s = s.replace(userIdPattern, user_id );

可查阅www.aboutthing.com@param1=用户名称,param2=用户_id。

有些人能够帮助我在 j瓦一层做这件事,重新唤醒经常表达是不够的。

这是在java审判的。

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());

引出这一错误

Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition near index 1 /({{^)([A-Za-z0-9_^}}{{, ])*(})/

问题回答

<代码>{>为 Java regexes的美容特性,用于约束性重复,例如a{1,2}<>>> > 至少对应1, 至少2 a s。 由于你没有重复使用,你应当从<代码>{>到<代码>>>>上填写。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签