regex

regexp pattern across multiple lines

笑着哭i 提交于 2021-01-28 22:17:20
问题 I have a long regexp pattern that needs to be matched in TCL regexp {.*%MKA-5-SESSION_START: +\((.*) +:.*\) +MKA Session started for.*([0-9A-Fa-f]{4}.[0-9A-Fa-f]{4}.[0-9A-Fa-f]{4}).*AuditSessionID +(.*), +AuthMgr-Handle +(.*)} $op - intf mac auditsessid authmgrhdl How can i split this to multiple lines , splitting using \ is not working as regexp fails. Thanks, Agnel. 回答1: That is a monster RE. The easiest way to split it up would be to use an extended mode RE by putting (?x) at the start of

Delete HTML element if it contains a certain amount of numeric characters

纵饮孤独 提交于 2021-01-28 21:42:41
问题 For transforming a html-formatted file to a plain text file with Python , I need to delete all tables if the text within the table contains more than 40% numeric characters. Specifically, I would like to: identify each table element in a html file
 calculate the number of numeric and alphabetic characters in the text and the correpsonding ratio, not considering characters within any html tags
. Thus, delete all html tags. delete the table if its text is composed of more than 40% numeric

RegEx to select a space between two digits

可紊 提交于 2021-01-28 20:56:48
问题 Given a string as the following, containing only 0 and 1 separated by spaces with an additional space at the end of each line. I want to select only the spaces between the digits but not the one at the end of the line to search and replace them with , . When I try to create a RegEx I either select all spaces or the surrounding digits too. GIVEN WANTED NOT WANTED TOTALLY NOT WANTED 0 1 0 1 0,1,0,1 0,1,0,1, ,,,, 0 0 1 0 0,0,1,0 0,0,1,0, ,,,, 1 0 1 0 1,0,1,0 1,0,1,0, ,,,, 1 1 0 0 1,1,0,0 1,1,0,0

regex to get word between two undescores

偶尔善良 提交于 2021-01-28 20:19:49
问题 I've a line like bla_bla**_**test**_1**023 and would like to extract the word between _ and any underscore followed by digit _digit which is test in the above example. I've tried the following regex but unfortunately does not work: [^_ ]+(?=[ _\d]) - it getting me all words before "_digit" not only the one which is before _digit 回答1: This should work for you. Use Pattern and Matcher with look-arounds . public static void main(String[] args) { String word= "bla_bla_test_1023"; Pattern p =

How to split a huge string by date using JavaScript?

穿精又带淫゛_ 提交于 2021-01-28 19:55:57
问题 I've got a pdf file turned into a huge string of over 1,000,000 characters. There are dates in the string in the format dd/mm/yyyy . I want to split the string by dates into smaller ones. I tried following: var sectioned = hugeString.split(/^(0?[1-9]|[12][0-9]|3[01])[\/](0?[1-9]|1[012])[\/\-]\d{4}$/g); But it's not working. I also tried hugeString.match() , but no good result there. Is it even possible to accomplish this by string functions or should I think of a different approach? String

Regex FullName Pattern

筅森魡賤 提交于 2021-01-28 19:51:05
问题 Tried looking around for a regex pattern for a full name and just can't seem to find one. Ideally would match like Tom Franklin tom Franklin tom franklin tom franklin-jones i.e. allow 1 space in the middle and some basic hyphens etc but thats all. Does any one know how to do this ? Edit: Including René Hadron van der Ööps 回答1: You can use /([\p{L}'-]+) ([\p{L}'-]+)/ to catch all possible letter. Or /([a-z'-]+) ([a-z'-]+)/i to catch only ascii letters. The group ([\p{L}'-]+) means [\p{L}'-]

regex for alphanumeric only is not working

元气小坏坏 提交于 2021-01-28 19:30:15
问题 This is the code I am trying: string MatchNumberPattern = "^[a-zA-Z0-9]*$"; if (!Regex.IsMatch(cueTextBox9.Text, MatchNumberPattern)) { MessageBox.Show("Enter 8 Space Alphanumeric BT ID only"); cueTextBox9.Text = String.Empty; } else { do something(); } It's accepting aaaaaaaa , but I want a combination of both alpha and numbers like aaaa1234 . 回答1: To require both a letter and a digit to appear in the input, you need positive lookaheads : @"^(?=.*[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]*$" ^^^^^^^^^^

Delete HTML element if it contains a certain amount of numeric characters

淺唱寂寞╮ 提交于 2021-01-28 19:27:49
问题 For transforming a html-formatted file to a plain text file with Python , I need to delete all tables if the text within the table contains more than 40% numeric characters. Specifically, I would like to: identify each table element in a html file
 calculate the number of numeric and alphabetic characters in the text and the correpsonding ratio, not considering characters within any html tags
. Thus, delete all html tags. delete the table if its text is composed of more than 40% numeric

regex for alphanumeric only is not working

有些话、适合烂在心里 提交于 2021-01-28 19:22:37
问题 This is the code I am trying: string MatchNumberPattern = "^[a-zA-Z0-9]*$"; if (!Regex.IsMatch(cueTextBox9.Text, MatchNumberPattern)) { MessageBox.Show("Enter 8 Space Alphanumeric BT ID only"); cueTextBox9.Text = String.Empty; } else { do something(); } It's accepting aaaaaaaa , but I want a combination of both alpha and numbers like aaaa1234 . 回答1: To require both a letter and a digit to appear in the input, you need positive lookaheads : @"^(?=.*[a-zA-Z])(?=.*[0-9])[a-zA-Z0-9]*$" ^^^^^^^^^^

Why it doesn't replace correctly if I run multiple replace checks?

▼魔方 西西 提交于 2021-01-28 19:11:01
问题 I am replacing smile character like :) to images. If I use only var yorum4 = "hello :)"; yorum4 = yorum4.replace(/(:\))/g, "<img class='smileys' src='smile.png' \/>"); It replaces correctly. However, when I use this for multiple replaces, yorum4 = yorum4.replace(/(:\))/g, "<img class='smileys' src='smile.png' \/>"); yorum4 = yorum4.replace(/(:\()/g, "<img class='smileys' src='smile1.png' \/>"); yorum4 = yorum4.replace(/(;\))/g, "<img class='smileys' src='smile2.png' \/>"); It corrupts and