regex

Regular Expression for field must contain at least 2 non-space alphanumeric characters

一个人想着一个人 提交于 2021-02-05 07:56:06
问题 Rule: field must contain at least 2 non-space alphanumeric characters. please any one can guide us how to write the regular expression thanks in advance.... 回答1: Match one alphanumeric character followed by zero or more characters followed by another alphanumeric character: \w.*\w If the validation automatically adds ^ and $, you have to match the characters before and after also: .*\w.*\w.* The \w code matches A-Z, a-z, 0-9 and _. If you have a different definition for aplhanumeric

Regular Expression to not allow 3 consecutive characters

自作多情 提交于 2021-02-05 07:55:32
问题 I have the following regex: Regex pattern = new Regex(@"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,20}/(.)$"); (?=.*\d) //should contain at least one digit (?=.*[a-z]) //should contain at least one lower case (?=.*[A-Z]) //should contain at least one upper case [a-zA-Z0-9]{8,20} //should contain at least 8 characters and maximum of 20 My problem is I also need to check if 3 consecutive characters are identical. Upon searching, I saw this solution: /(.)\1\1/ However, I can't make it to work

How to remove rows from a data frame that contain only few words in R?

梦想的初衷 提交于 2021-02-05 07:55:10
问题 I'm trying to remove rows from my data frame that contain less than 5 words. e.g. mydf <- as.data.frame(read.xlsx("C:\\data.xlsx", 1, header=TRUE) head(mydf) NO ARTICLE 1 34 The New York Times reports a lot of words here. 2 12 Greenwire reports a lot of words. 3 31 Only three words. 4 2 The Financial Times reports a lot of words. 5 9 Greenwire short. 6 13 The New York Times reports a lot of words again. I want to remove rows with 5 or less words. how can i do that? 回答1: Here are two ways:

Extracting multiple values with RegEx in a Google Sheet formula

谁说胖子不能爱 提交于 2021-02-05 07:54:29
问题 I have a Google spreadsheet with 2 columns. Each cell of the first one contains JSON data, like this: { "name":"Love", "age":56 }, { "name":"You", "age":42 } Then I want a second column that would, using a formula, extract every value of name and string it like this: Love,You Right now I am using this formula: =REGEXEXTRACT(A1, CONCATENER(CHAR(34),"name",CHAR(34),":",CHAR(34),"([^",CHAR(34),"]+)",CHAR(34),",")) The RegEx expresion being "name":"([^"]+)", The problem being that it currently

Extracting multiple values with RegEx in a Google Sheet formula

大憨熊 提交于 2021-02-05 07:53:07
问题 I have a Google spreadsheet with 2 columns. Each cell of the first one contains JSON data, like this: { "name":"Love", "age":56 }, { "name":"You", "age":42 } Then I want a second column that would, using a formula, extract every value of name and string it like this: Love,You Right now I am using this formula: =REGEXEXTRACT(A1, CONCATENER(CHAR(34),"name",CHAR(34),":",CHAR(34),"([^",CHAR(34),"]+)",CHAR(34),",")) The RegEx expresion being "name":"([^"]+)", The problem being that it currently

Python regex: How to increase only one number in string?

。_饼干妹妹 提交于 2021-02-05 07:52:06
问题 I have a string of following types: a1 = 'images1subimages1/folder100/hello1.png' a1 = 'images1subimages1 folder100 hello1.png' a1 = 'images1subimages1folder100hello1.png' a1 = 'images1b100d1.png' The first Integer of the string is num0 and we only care about it. We want to increase all occurrence of num0 by one and keep other numbers the same. Required: a2 = 'images2subimages2/folder100/hello2.png' a2 = 'images2subimages2 folder100 hello2.png' a2 = 'images2subimages2folder100hello2.png' a2 =

Python regex: How to increase only one number in string?

旧街凉风 提交于 2021-02-05 07:52:00
问题 I have a string of following types: a1 = 'images1subimages1/folder100/hello1.png' a1 = 'images1subimages1 folder100 hello1.png' a1 = 'images1subimages1folder100hello1.png' a1 = 'images1b100d1.png' The first Integer of the string is num0 and we only care about it. We want to increase all occurrence of num0 by one and keep other numbers the same. Required: a2 = 'images2subimages2/folder100/hello2.png' a2 = 'images2subimages2 folder100 hello2.png' a2 = 'images2subimages2folder100hello2.png' a2 =

convert C# regex to Java Regex

心不动则不痛 提交于 2021-02-05 07:49:06
问题 Any simple unicode string like زسس or یسیتنانت matches in c# regex using the following pattern but they don’t match in java. Can anyone explain this? How do I correct it for it to work in Java? "\\b[\\w\\p{M}\\u200B\\u200C\\u00AC\\u001F\\u200D\\u200E\\u200F]+\\b" c# code :(it matches the strings) private static readonly Regex s_regexEngine; private static readonly string s_wordPattern = @"\b[\w\p{M}\u200B\u200C\u00AC\u001F\u200D\u200E\u200F]+\b"; static PersianWordTokenizer() { s_regexEngine

Extract data from HTML table row column

不打扰是莪最后的温柔 提交于 2021-02-05 07:47:26
问题 How to extract data from HTML table in PHP. The data is in this format Table 1 <tr><td class="body" valign="top"><a href="example"><b>DATA</b></a></td><td class="body" valign="top">Data_Text</td></tr> Table 2 <tr><th><div id="Data">Data</div></th><td>Data_Text_1</td><td>Data_Text_2</td></tr> Table 3 <tr><td width="120"><a href="example" target="_blank">DATA</a></td><td>Data_Text</td></tr> I want to get the Data & Data_Text or (Data_Text_1 & Data_Text_2) from the 3 tables . I've used $html =

Replace text with tokens from a list using regular expression

好久不见. 提交于 2021-02-05 07:43:16
问题 I'm trying to write a simple text replacer in React.js using a regular expression but I can't wrap my head around it. So I've got a list of tokens and their corresponding replacement text. I also have a text area with text written by the user. Whenever a word is wrapped around { } the text will be replaced with the replacement text of the corresponding token. For example if I have a {example} somewhere in my textarea I will have to check my tokenlist and see if I have the value example in the