草庐IT

REGEX_EXTRACT

全部标签

regex - 如何在 Swift 中使用正则表达式?

我正在用Swift开发一个应用程序,我需要从一个字符串中捕获8个数字。这是字符串:index.php?page=index&l=99182677我的模式是:&l=(\d{8,})这是我的代码:varyourAccountNumber="index.php?page=index&l=99182677"letregex=try!NSRegularExpression(pattern:"&l=(\\d{8,})",options:NSRegularExpressionOptions.CaseInsensitive)letrange=NSMakeRange(0,yourAccountNumbe

regex - 正则表达式与 Swift 中元字符的大小写和变音符号不敏感匹配

我正在尝试匹配用户输入中的粗鲁词语,例如“我恨你!”或“i.håté.Yoù”将与从JSON解析的单词数组中的“恨你”相匹配。所以我需要它不区分大小写和变音符号,并将粗鲁单词中的空格视为任何非字母字符:正则表达式元字符\P{L}应该适用于此,或者至少\W现在我知道[cd]与NSPredicate一起工作,就像这样:funcmatches(text:String)->[String]?{ifletrudeWords=JSON?["words"]as?[String]{returnrudeWords.filter{letpattern=$0.stringByReplacingOccurre

c - swift (Linux) : Extract CMS/PKCS#7 Certs and Validate Container Signature?

我正在用Swift4编写一组将在Linux上运行的服务。我需要做的一件事是接收使用加密消息语法(CMS)格式进行数字签名的有效负载,提取用于对其进行签名的证书,然后验证签名。我知道Linux上的Swift不包含用于此类事情的Security或CommonCrypto框架,因此我已经链接到OpenSSL以尝试帮助解决这个问题。我已经离开我的C/C++编程时代大约2年了,所以我欣然承认我在这部分代码上不知所措。我有2个简单的类作为OpenSSL的包装器BIO和PKCS7数据结构。它们看起来像这样:importFoundationimportOpenSSLpublicfinalclassBI

swift - git log -L :<funcname>:<file> 的 "the function name regex"是什么

我的文件中有以下Swift函数Main/VProj/AppModel.swiftfunccreateItemAndSegment(image:UIImage,completionHandler:(Item?,NSError?)->Void){\\[...]}gitlog-L::的文档州-L,:-L::Tracetheevolutionofthelinerangegivenby","(orthefunctionnameregex)withinthe.但是命令gitlog-L:createItemAndSegment:Main/VProj/AppModel.swiftgitlog-L:'c

regex - 确保正则表达式与 Swift 正则表达式匹配整个字符串

如何检查整个字符串是否可以与正则表达式匹配?在Java中是方法String.matches(regex) 最佳答案 您需要使用anchor,^(字符串anchor的开始)和$(字符串anchor的结尾),通过range(of:options:range:locale:),传递.regularExpression选项:importFoundationletphoneNumber="123-456-789"letresult=phoneNumber.range(of:"^\\d{3}-\\d{3}-\\d{3}$",options:.r

java - java.util.regex.Pattern 可以进行部分匹配吗?

是否有可能知道流/字符串是否包含可以匹配正则表达式的输入。例如Stringinput="AA";Patternpat=Pattern.compile("AAAAAB");Matchermatcher=pat.matcher(input);//或Stringinput="BB";Patternpat=Pattern.compile("AAAAAB");Matchermatcher=pat.matcher(input);//谢谢 最佳答案 是的,Java提供了一种方法来做到这一点。首先,您必须调用一种标准方法来应用正则表达式,例如mat

java.util.regex.PatternSyntaxException : Unclosed character class near index 0

我正在尝试替换我的字符串中的所有方括号。这是我的程序packagecom;importjava.util.ArrayList;importorg.apache.commons.lang3.StringUtils;importorg.json.JSONException;publicclassTeste{/***@paramargs*@throwsJSONException*/publicstaticvoidmain(String[]args)throwsJSONException{Stringstr="[Fountain#Apple#Big(7)]";str.replaceAll("[

用于验证印度语言字符的 Java REGEX 代码不起作用?

为什么以下代码对印度语言不起作用(结果为false)?System.out.println(Charset.forName("UTF-8").encode("అనువాద").asCharBuffer().toString().matches("\\p{L}+"));System.out.println(Charset.forName("UTF-8").encode("स्वागत").asCharBuffer().toString().matches("\\p{L}+"));System.out.println(Charset.forName("UTF-8").encode("நல்

regex - 这些特殊字符在 Java 中是什么意思?

我在看一些jdk代码。我找到了这些字符。谁能给我解释一下这些是什么意思。publicstaticStringquote(Strings){intslashEIndex=s.indexOf("\\E");//Whatdoesthismean.Isthisaspecialcharinjava.ifsowhatdoesthisdo.if(slashEIndex==-1)return"\\Q"+s+"\\E";StringBuildersb=newStringBuilder(s.length()*2);sb.append("\\Q");slashEIndex=0;intcurrent=0;wh

java.util.regex.PatternSyntaxException : Dangling meta character '+' near index 0 +

我在启动UI时遇到错误,导致此代码在标题中向我吐出错误。它适用于我的所有其他运算符符号,所以我真的不确定这里发生了什么。我不想发布所有代码,所以如果这还不够,您可以在我的gitHub上找到其余代码:https://github.com/jparr721/Calculator-App/tree/master/src/calculatorpublicclassCalculation_Controls{publicdoubleA,B;privateString[]operators=newString[]{"-","+","/","*","x","^","X"};/***Checkforth