regex

Python - find a substring between two strings based on the last occurence of the later string

半城伤御伤魂 提交于 2021-02-08 12:11:44
问题 I am trying to find a substring which is between to strings. The first string is <br> and the last string is <br><br> . The first string I look for is repetitive, while the later string can serve as an anchor. Here is an example: <div class="linkTabBl" style="float:left;padding-top:6px;width:240px"> Anglo American plc <br> 20 Carlton House Terrace <br> SW1Y 5AN London <br> United Kingdom <br><br> Phone : +44 (0)20 7968 8888 <br> Fax : +44 (0)20 7968 8500 <br> Internet : <a class="pageprofil

Perl comprehensive phone number regex [duplicate]

杀马特。学长 韩版系。学妹 提交于 2021-02-08 12:11:19
问题 This question already has answers here : How to validate phone numbers using regex (42 answers) Closed 2 years ago . I have a file that contains phone numbers of the following formats: (xxx) xxx.xxxx (xxx).xxx.xxxx (xxx) xxx-xxxx (xxx)-xxx-xxxx xxx.xxx.xxxx xxx-xxx-xxxx xxx xxx-xxxx xxx xxx.xxxx I must parse the file for phone numbers of those and ONLY those formats, and output them to a separate file. I'm using perl, and so far I have what I think is a valid regex for two of these numbers my

How to validate UITextfield that satisfies 5 different conditions using shouldChangeCharactersInrange method?

柔情痞子 提交于 2021-02-08 11:54:33
问题 I’m trying to validate a Password Textfield in realtime (Swift 4.2 & Xcode 10.2.1). My question is how to validate the conditions listed below in UITextField's shouldChangeCharactersInrange method? Minimum 8 characters Maximum 50 characters Minimum 1 alphabet Minimum 1 number No special characters Also, there will be a gray color tick image on the left side of all 4 validation messages. As long as the condition are not met, image will be gray color tick. If validation succeeds, tick images

how to use regex in switch case in expect script?

本小妞迷上赌 提交于 2021-02-08 11:45:47
问题 Normally, switch case in expect looks like this: switch -- $count \ 1 { set type byte } 2 { set type word } big { set type array } default { puts "$count is not a valid type" } I need to use regex operators such as | or & - how can I do that? The below example does not work with expect code : switch -- $variable \ ("a"|"b"|"c") { do something } ("a"|"b"|"c") represents a or b or c, but it does not seem to work. How do I use such statements in switch or may be an and statement? 回答1: Use the

Python - Parsing and converting string into timestamp [closed]

本小妞迷上赌 提交于 2021-02-08 11:21:26
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago . Improve this question I have string in next format: 2017-02-14T09:51:46.000-0600 What is the best approach to parse and convert string into timestamp? I have options to use regular expression or to write my own function for parsing, but are there any builtin methods which can

Oracle select mutual sub string

喜你入骨 提交于 2021-02-08 11:19:29
问题 I would like to return new table in ORACLE where all rows that have same the values in 'col' columns group together and the 'description' column will contain only the mutual sub strings when the different characters will replaced by '...' how can I do that? May i get your help please? Basic code to start with: SELECT col,description FROM table group by col; Example 1: col description 1 Today is 1 Today is a good day 1 Today is perfect day 2 Hello world 2 Hello results: col description 1 Today

Python domain name check using regex

纵然是瞬间 提交于 2021-02-08 11:05:29
问题 I wish to set up a user input check for domain names. I found the following on stackoverflow Check for a valid domain name in a string?, and the answer: r'[a-zA-Z\d-]{,63}(.[a-zA-Z\d-]{,63})*' seems to suits my needs (in concept) but when I test it using re.match and a string greater than 63 characters it still returns 'true'. When I test the result using group() it returns the first 63 characters, which makes sense. Based on that can someone please tell me what I'm doing wrong? Is Match the

Python domain name check using regex

末鹿安然 提交于 2021-02-08 11:03:20
问题 I wish to set up a user input check for domain names. I found the following on stackoverflow Check for a valid domain name in a string?, and the answer: r'[a-zA-Z\d-]{,63}(.[a-zA-Z\d-]{,63})*' seems to suits my needs (in concept) but when I test it using re.match and a string greater than 63 characters it still returns 'true'. When I test the result using group() it returns the first 63 characters, which makes sense. Based on that can someone please tell me what I'm doing wrong? Is Match the

Reasons for not using `\s` and `\S`

大城市里の小女人 提交于 2021-02-08 11:01:40
问题 In GNU sed answers using the regular expression extensions \s which matches whitespace caracters and its dual \S which matches non-whitespace characters, seem to be shied from. Why is this? 回答1: They're GNU-only and so non-portable to other seds, that's all. Just wrt matching white space and use of -E (idk about the rest), the example you referenced would work with OSX/BSD sed or GNU sed as written, but if you used \s instead of [ \t] then it'd stop working in OSX/BSD sed. Personally I'd have

Reasons for not using `\s` and `\S`

 ̄綄美尐妖づ 提交于 2021-02-08 11:01:14
问题 In GNU sed answers using the regular expression extensions \s which matches whitespace caracters and its dual \S which matches non-whitespace characters, seem to be shied from. Why is this? 回答1: They're GNU-only and so non-portable to other seds, that's all. Just wrt matching white space and use of -E (idk about the rest), the example you referenced would work with OSX/BSD sed or GNU sed as written, but if you used \s instead of [ \t] then it'd stop working in OSX/BSD sed. Personally I'd have