regex

How to parse Ical file from Facebook Events in PHP Regex?

人盡茶涼 提交于 2021-02-05 09:37:26
问题 I am trying to parse the Summary and DTSTART fields in this data and thought about using regex. Also tried reading line by line but couldn't work around the logic to implement it. Anyone help out? There are already made parsers out there but my requirements are abit unique and require a different targeted implementation. BEGIN:VCALENDAR PRODID:-//Facebook//NONSGML Facebook Events V1.0//EN X-WR-CALNAME:Friends' birthdays X-PUBLISHED-TTL:PT12H X-ORIGINAL-URL:/events/birthdays/ VERSION:2.0

Splitting a space separated string

大憨熊 提交于 2021-02-05 09:36:55
问题 String numbers = "5 1 5 1"; So, is it: String [] splitNumbers = numbers.split(); or: String [] splitNumbers = numbers.split("\s+"); Looking for: ["5","1","5","1"] Any idea why neither of the .split lines will work? I tried reading answers about the regex, but I'm not getting anywhere. 回答1: You must escape the regex with an additional \ since \ denotes the escape character: public static void main(String[] args) { String numbers = "5 1 5 1"; String[] tokens = numbers.split("\\s+"); for(String

Regular expressions match exact word

杀马特。学长 韩版系。学妹 提交于 2021-02-05 09:35:50
问题 I am looking to build a regular expression that matches only the occurrences of the text passed. I tried using the \b which indeed worked for a word boundary but it didn't work with symbols like ! . >>> list(re.finditer(r'\bhe\b','he is hey!')) [<re.Match object; span=(0, 2), match='he'>] >>> list(re.finditer(r'\bhe\b','he is he!')) [<re.Match object; span=(0, 2), match='he'>, <re.Match object; span=(6, 8), match='he'>] I don't want my regular expression to match the 'he!' 回答1: You might

Using OR (|) with PHP Regex when ORing two expressions

人盡茶涼 提交于 2021-02-05 09:34:39
问题 I'm trying to combine two regular expressions with an OR condition in PHP so that two different string patterns can be found with one pass. I have this pattern [\$?{[_A-Za-z0-9-]+[:[A-Za-z]*]*}] which matches strings like this ${product} and ${Product:Test} . I have this pattern [<[A-Za-z]+:[A-Za-z]+\s*(\s[A-Za-z]+=\"[A-Za-z0-9\s]+\"){0,5}\s*/>] which matches strings like this <test:helloWorld /> and <calc:sum val1="10" val2="5" /> . However when I try to join the two patterns into one [\$?{[

Regular expressions match exact word

自作多情 提交于 2021-02-05 09:34:25
问题 I am looking to build a regular expression that matches only the occurrences of the text passed. I tried using the \b which indeed worked for a word boundary but it didn't work with symbols like ! . >>> list(re.finditer(r'\bhe\b','he is hey!')) [<re.Match object; span=(0, 2), match='he'>] >>> list(re.finditer(r'\bhe\b','he is he!')) [<re.Match object; span=(0, 2), match='he'>, <re.Match object; span=(6, 8), match='he'>] I don't want my regular expression to match the 'he!' 回答1: You might

Regex for validating date in dd-Mmm-yyyy format

a 夏天 提交于 2021-02-05 09:33:35
问题 I have an text input box which needs to be validated. The user should be only able to enter the date in dd-Mmm-yyyy format. ex: 01-Jun-2013, 31-Aug-2015 and so on. Or they should be able to enter T+1, T+2,...T+99. What kind of a regex pattern I could use to validate both of these. I think for validating the dd-Mmnm-yyyy, the following regex works: ^(([0-9])|([0-2][0-9])|([3][0-1]))\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\-\d{4}$ Please help me with this! Update: I just need the

REgex to get numeric from string in oracle

梦想与她 提交于 2021-02-05 09:33:28
问题 I have strings in the following formats Akram_88_jamesstree_20140418, Akram_8_johnstreet_20140418, Akram_888_johnstreet_20140418, Now I want to retrieve only the 88,8 and 888 value only, for which i have written the following query SUBSTR(a.file_name, 7, INSTR(a.file_name, '_')-5) as output now the problem with this query is i just get 88 -8 and 88 of 888. The output will be compared to another column so i want just 88,8 and 888 numeric values. 回答1: SELECT REGEXP_SUBSTR('Akram_88_jamesstree',

Regex for validating date in dd-Mmm-yyyy format

[亡魂溺海] 提交于 2021-02-05 09:33:11
问题 I have an text input box which needs to be validated. The user should be only able to enter the date in dd-Mmm-yyyy format. ex: 01-Jun-2013, 31-Aug-2015 and so on. Or they should be able to enter T+1, T+2,...T+99. What kind of a regex pattern I could use to validate both of these. I think for validating the dd-Mmnm-yyyy, the following regex works: ^(([0-9])|([0-2][0-9])|([3][0-1]))\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\-\d{4}$ Please help me with this! Update: I just need the

Find correct regex

好久不见. 提交于 2021-02-05 09:29:48
问题 I'm trying to find the correct regex for this case: ???-1.1.0-??? I need prefix and suffix between version, ? can be everything (letter, number or nothing) What I have : static check(version: string) { return /-(\d+)\.(\d+)\.(\d+)-$/.test(version); } THanks for your help :) 回答1: Wouldn't "???-1-" still be the "prefix", there is no way to tell by a simple regex, you will need to capture everything between number, dot, number, etc... until you meet another dash. Breakdown There are three groups

Find correct regex

不打扰是莪最后的温柔 提交于 2021-02-05 09:29:36
问题 I'm trying to find the correct regex for this case: ???-1.1.0-??? I need prefix and suffix between version, ? can be everything (letter, number or nothing) What I have : static check(version: string) { return /-(\d+)\.(\d+)\.(\d+)-$/.test(version); } THanks for your help :) 回答1: Wouldn't "???-1-" still be the "prefix", there is no way to tell by a simple regex, you will need to capture everything between number, dot, number, etc... until you meet another dash. Breakdown There are three groups