regex

python regex to match whole line with a particular regex pattern

廉价感情. 提交于 2021-02-18 17:40:14
问题 I have a file with a list of regex patterns and string containing '\n's' i.e a string with seperate lines ... I need a generic regex that can match the whole line with patterns in the regex file such that i can do something like re.compile(r'generic_regex%s') %regex_pattern from file and it automatically matches the whole line much like grep. Any ideas?? 回答1: Something like: >>> re.findall(r"(^.*?%s.*?$)" %expression, text, re.MULTILINE) ? 回答2: Adjust for any boundaries etc... import re

Google Scripts - Grab email address from bounced message and parse information

岁酱吖の 提交于 2021-02-18 17:18:13
问题 Good Morning, I am a newbie to javascript, google scripts, and regex. I have found very good information from Amit Agarwal at https://www.labnol.org/internet/gmail-bounced-email-report/29209/, but I'm having difficulty identifying what I specifically need to keep or need to update. Rather than using the bounce mailer-daemon addresses, I would like to grab the bounced messages from two labels in my gmail account (MinervaBounce and MILSBounce) and be able to differentiate which one the message

Google Scripts - Grab email address from bounced message and parse information

守給你的承諾、 提交于 2021-02-18 17:17:25
问题 Good Morning, I am a newbie to javascript, google scripts, and regex. I have found very good information from Amit Agarwal at https://www.labnol.org/internet/gmail-bounced-email-report/29209/, but I'm having difficulty identifying what I specifically need to keep or need to update. Rather than using the bounce mailer-daemon addresses, I would like to grab the bounced messages from two labels in my gmail account (MinervaBounce and MILSBounce) and be able to differentiate which one the message

PySpark UDF optimization challenge using a dictionary with regex's (Scala?)

ぐ巨炮叔叔 提交于 2021-02-18 17:09:50
问题 I am trying to optimize the code below (PySpark UDF). It gives me the desired result (based on my data set) but it's too slow on very large datasets (approx. 180M). The results (accuracy) are better than available Python modules (e.g. geotext, hdx-python-country). So I'm not looking for another module. DataFrame: df = spark.createDataFrame([ ["3030 Whispering Pines Circle, Prosper Texas, US","John"], ["Kalverstraat Amsterdam","Mary"], ["Kalverstraat Amsterdam, Netherlands","Lex"] ]).toDF(

Scrapy parse javascript

眉间皱痕 提交于 2021-02-18 11:22:39
问题 I have a javascript on the page like below: new Shopify.OptionSelectors("product-select", { product: {"id":185310341,"title":"10. Design | Siyah \u0026 beyaz kalpli", i want to get "185310341". I am searching on google about a few hours but couldn't find anything, I hope u can help me. How can i scrape that javascript and get that id? I tried that code : id = sel.search('"id":(.*?),',text).group(1) print id but i got: exceptions.AttributeError: 'Selector' object has no attribute 'search' 回答1:

How to use 'where' on column with comma separated values in laravel

倖福魔咒の 提交于 2021-02-18 11:20:07
问题 I am using php with laravel framework. I want to get rows from table that contains user id. Problem here is that user id is integer value and column(author) contain more than one comma separated integer values. Here is example. DB::table('stories')->where('author','4')->get(); author column have values : row 1: 2,4,5 | row 2: 1,3,14 | row 3 : 4,5 and I will get row 1 and 3. So, Please help me to get right rows. 回答1: You can use whereRaw like as DB::table('stories')->whereRaw("find_in_set('4'

What is the urls.py regex evaluation order in django?

二次信任 提交于 2021-02-18 11:03:19
问题 I was having some problems with the regex in urls.py (I am a beginner to django as well as regexes in general) Here is my original urls.py url(r'^name/(?P<name>\w+)/$', 'course.views.name'), url(r'^', 'course.views.index'), And I was trying to access it using this: http://127.0.0.1:8000/name/blah/ My view looks like: def index(request): return HttpResponse("Hello, sam. You're at the course index.") def name(request, name): return HttpResponse("Hello, %s. You're at the course index." % name)

What is the urls.py regex evaluation order in django?

╄→尐↘猪︶ㄣ 提交于 2021-02-18 11:03:04
问题 I was having some problems with the regex in urls.py (I am a beginner to django as well as regexes in general) Here is my original urls.py url(r'^name/(?P<name>\w+)/$', 'course.views.name'), url(r'^', 'course.views.index'), And I was trying to access it using this: http://127.0.0.1:8000/name/blah/ My view looks like: def index(request): return HttpResponse("Hello, sam. You're at the course index.") def name(request, name): return HttpResponse("Hello, %s. You're at the course index." % name)

Optimization techniques used by std::regex_constants::optimize

六月ゝ 毕业季﹏ 提交于 2021-02-18 10:58:43
问题 I am working with std::regex , and whilst reading about the various constants defined in std::regex_constants , I came across std::optimize , reading about it, it sounds like it is useful in my application (I only need one instance of the regex, initialized at the beginning, but it is used multiple times throughout the loading process). According to the working paper n3126 (pg. 1077), std::regex_constants::optimize : Specifies that the regular expression engine should pay more attention to

Using regex to find sql parameters in a string

≯℡__Kan透↙ 提交于 2021-02-18 10:47:07
问题 I am using the following regex expression to find SQL parameters, but it is not working under some circumstances. \@([^=<>\s]+)((?=\s)|$) If I use this SQL query, select count(1) from (select * from tblEmailList109 where firstname='@FirstName') t the value returned is: @Firstname') How can I modify the regex to stop stop but do not include a single quote, a space, or the end of the string? My intention is the replace the parameter before passing it to the SQL server. I know having the single