在<>之间读取的Java常规压缩 [英] Java regular espressions read between<>

查看:60
本文介绍了在<>之间读取的Java常规压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在<><>之间读取的代码;

 import java.util.Arrays; 
public class StringR
{
public static void main(String args [])
{
String Android =Android is os for mobile phones and
+cs [ad< cs> adwords< cs>;

System.out.println(< cs>< cs>之间的字,即adwords);
}
}



还有另一种方法可以读取特殊字符之间的代码或特殊字符之后的内容;

正常的方式是模式和匹配器但是当涉及到特殊字符时这不是很可定制的;



我尝试过的方法:



常规espressions for java;它的作用是匹配模式,但代码应在特殊字符之后或之间读取,例如[()} ^&

解决方案

引用:

还有另一种代码可以在特殊字符之间读取或者在特殊字符之后读取字符;

正常的方式是模式和匹配器,但是当涉及到特殊字符时,这不是很可定制的。



是的,你总能建立自己的'解析器'得到你想要的东西,RegEx只是一个标准化的工具来完成这项工作。

求助,你需要d显示一些样品,并显示每个样品,并显示您使用的RegEx。


我强烈建议您阅读: Java正则表达式 [ ^ ]和: Java Regex |正则表达式 - javatpoint [ ^ ]。在那里你会找到一些例子,你可以根据自己的需要改变它们。





另一种方法是使用 StringUtils ,请参阅:如何查找文本之间的文本两串? | Kode Java [ ^ ]

code that reads between <><> ;

import java.util.Arrays;
public class StringR 
{
     public static void main(String args[]) 
     {
        String Android = "Android is os for mobile phones and"
                            +"cs [ ad <cs>adwords<cs>"; 

       System.out.println(word between <cs><cs>which is adwords);
     }     
}


is there another way for code that reads between special characters or what is after special characters;
the normal way being pattern and matcher but that is not very customizable when special characters are involved;

What I have tried:

regular espressions for java;what it does is matches pattern but the code should read after or between special characters say for instance [ () }^&

解决方案

Quote:

is there another way for code that reads between special characters or what is after special characters;
the normal way being pattern and matcher but that is not very customizable when special characters are involved.


Yes, you always can build your own 'parser' to get what you want, RegEx is just a standardized tool to do the job.
For help, you need to show a few samples with what you want to get in each, and show the RegEx you use.


I'd strongly recommend to read this: Java Regular Expressions[^] and this: Java Regex | Regular Expression - javatpoint[^] . There you'll find set of examples, which you can change to your needs.


Another way is to use StringUtils, see: How do I find text between two strings? | Kode Java[^]


这篇关于在&lt;&gt;之间读取的Java常规压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆