Menu
  • HOME
  • TAGS

Using regex to match sentences that may include quote marks “”

python,regex,python-3.x,findall

What's wrong with /starting string foo (.*)\</ ...

Findall inside findall

prolog,findall

From the comments it seems you need all the routes that pass through a given station S. findall(R, (route(R, Stations, _), member(S, Stations)), Routes). The goal is a conjunction of two conditions: that R is the number of some route that goes through the list of stations Stations and that...

Find string that isn't proceeded by other string

regex,visual-studio-2012,regex-negation,findall

I think you need a pattern like this ClientTemplate.*KeyPhrase Demo Or if you want a string that is NOT proceeded by KeyPhrase you could use a negative lookahead like this ClientTemplate(?!.*KeyPhrase.*$).*$ Demo...

How does this code work to extract URL's from a string with regex

python,regex,python-3.x,string-parsing,findall

Using this link you can get your regex explained: Your regex explained To add a bit more: [s]? means "an optional 's' character" but that's because of the ? not of the brackets [I think they are superfluous. Space isn't one of the accepted characters so it would stop there...

Python web-scraping error - TypeError: can't use a string pattern on a bytes-like object

python-3.x,web-scraping,scraper,findall

You have to decode your data. Since the website in question says charset=iso-8859-1 use that. utf-8 won't work in this case. htmltext = htmlfile.read().decode('iso-8859-1') ...

using re.findall() in python

python,regex,web-crawler,findall

The problem is with your regex. There are a whole bunch of ways I could write a valid HTML anchor that your regex wouldn't match. For example, there could be extra whitespace, or line breaks in it, and there are other attributes that could exist that you haven't taken into...

Yii - loop an array from findAll

yii,findall

You are setting $limit to count($files) but using $i<=$limit in your loop. Should be < instead. for($i=0; $i<$limit; $i++){ Since there is a chance of an external $limit being applied you could use a foreach loop with a conditional break. foreach($files as $a => $file) { if($a == $limit) {...

JPA custom findOne and findAll

jpa,customization,spring-data,findall

With Hibernate, you can try annotating your entity with @Where, something like this @Entity @Where(clause = "state = 'ACTIVE'") public class Place {...} ...

Python Regex pattern findall

python,regex,greedy,findall

.+ is greedy by default. You need to add ? reluctant quantifier next to the + to do a non-greedy match. get_tags = lambda t: re.findall(r"<(.+?)>", t) OR get_tags = lambda t: re.findall(r"<([^<>]+)>", t) [^<>]+ negated character class which matches any character but not of > or < one or...

Grails findAll closure combine query with hasmany field

grails,groovy,gorm,findall

and... Construction VisitSchedules.findAll, VisitSchedules.where and VisitSchedules.withCriteria are not self-sufficient and not reliable. Always use construction VisitSchedules.createCriteria(). class VisitScheduleService { def springSecurityService void run{ SecUser currentUser = springSecurityService.currentUser def upcomingVisitSchedules = VisitSchedules.createCriteria().list() { and { visit { le('startTime', new DateTime()) } eq('user', currentUser) } } } } ...

chunk of data into fixed lengths chunks and then add a space and again add them all as a string

regex,list,join,ironpython,findall

You can simply do x="a85b080040010000" print re.sub(r"(.{2})",r"\1 ",x) or x="a85b080040010000" print " ".join([i for i in re.split(r"(.{2})",x) if i]) ...

python regex match case option

python,regex,findall,ignore-case

You can enforce the case insensitive search inside the comprehension: searchString = "maki" itemList = ["Maki", "moki", "maki", "Muki", "Moki"] resultList =[] matchCase = 1 if matchCase: resultList = [x for x in itemList if x == searchString] else: resultList = [x for x in itemList if x.lower() == searchString.lower()]...

How to use Beautiful Soup's find() instead of find_all() for better runtime

python,find,beautifulsoup,findall,bs4

According to the official documentation there is a way to search by the custom data-* attributes. You should try this: line = soup.find('img', attrs={'data-a-dynamic-image': True}) ...

Python findall, regex, unicode

python,regex,unicode,findall

When using glob with file names containing Unicode characters, use a Unicode string for the pattern. This makes glob return Unicode strings instead of byte strings. Printing Unicode strings automatically encodes them in the console's encoding when output. You will still have issues if your songs have characters not supported...

Grails - findAll joining two tables

grails,gorm,findall

So I did it slightly different, using criteria instead. Take a look if interested static getAllByUserAccount(UserAccount userAccount) { def criteria = Lightbox.createCriteria() def my_lb = criteria.list { users { eq('userAccount', userAccount) } } return my_lb } It seems to be working. Thanks for responses though...

Beautifulsoup find_all does not find all

python,beautifulsoup,web-crawler,findall

Here is the improved code with multiple fixes: use requests.Session maintained throughout the the script life cycle use urparse.urljoin() to join URL parts use CSS selectors instead of find_all() improved the way products are being found on the page transformed index-based loops into pythonic loops over list items The code:...

why findall/3 in swi-prolog ignores variable binding?

prolog,findall,prolog-setof

You can use bagof/3 for that: ?- X = Y, bagof(Element, Z^( member(Z, [a,b,c]), Element = Z:X ), Set). X = Y, Set = [a:Y, b:Y, c:Y]. From SWI-Prolog's documentation: findall/3 is equivalent to bagof/3 with all free variables bound with the existential operator (^), except that bagof/3 fails when...

How can I use regex in Python to return these numbers?

python,regex,findall

Here is a way to do it. First parse your string to get the json object (everything inside the most outer braces). Then decode the json object using the json module and access what you need. astr = '''var PRO_META_JSON = { "attributeDefinition":{ "defaultSku":305557121, "attributeListing":[{ "label":"Finish", "defaultIndex":0, "options":[ "White::f33b4086", "Beige::8e0900fa",...

How to get the hidden input's value by using python?

python,python-2.7,urllib2,findall

Using re module to parse xml or html is generally considered as bad practice. Use it only if you are responsable for the page you try to parse. If not, either your regexes are awfully complex, or your script could break if someone replaces <input type="hidden" name=.../> with <input name="..."...

How to make Python's findall regular expression method inclusive

python,regex,findall

You were quite near. Put the group to match the entire required portion rather than only the string in between >>> s = 'string with %%substring1%% and %%substring2%%' >>> import re >>> re.findall('(%%.*?%%)', s, re.DOTALL) ['%%substring1%%', '%%substring2%%'] You actually do not need the parens at all! >>> re.findall('%%.*?%%', s, re.DOTALL)...

Finding all solutions in prolog

prolog,findall

You've structured your test predicate so that bagof/3 is called for every instance combination of needs(N) and resources(R) and so it collects each result of make_bid in it's own bagof/3 result: ece3520 1 joel Bag = [[ece3520, 1, tu, 11, 14, joel, _G4310]] The first line is the write that...

Prolog - Operation inside findall

recursion,prolog,backtracking,findall

The reason you get different behaviours when querying run. and run2. is because the goal sumValue('M1', _, F) is being satisfied twice: ?- sumValue('M1', _, F). F = 3 ; F = 0. I would also recommend you to use format/2 instead of all those write/1 predicates. It helps for...

inconsitent behaviour of beautifulSoup

python,web-scraping,beautifulsoup,html-parsing,findall

The values you are looking for on the Yahoo Finance Page are updated periodically via a streaming API call in the browser. You would not get these values by just requesting the Reliance Industries Ltd (RELIANCE.NS) url using urllib or requests. The least complex option would be to automate a...

Using method FindAll in two generic lists

vb.net,generic-list,findall

You can use the AddRange method to add multiple items to a List. For Each n As BE_Busq In List_A LIST.AddRange(List_B.FindAll(Function(x As BE_Busq) x.ID = n.ID)) Next ...

How to Get List of Classes where string Property is null or Empty string value?

c#,asp.net,findall

Seems more a Page Lifecycle issue than FindAll. The statement is correct, besides you won't need the .ToList() as FindAll should already return a new List<T> instance.

How to search Single user From LADP:

findall,adam

Its works fine: eobjEntry = New DirectoryEntry("LDAP://" & m_strLDAPServer & ":" & m_strLDAPPort & "/" & "cn=" & txtUserName & "," & m_strLDAPEntry) 'set the user name and password, if necessary Dim search As New DirectorySearcher() 'here search & txtUserName & works SQL Like Operation objSearcher = New DirectorySearcher(objEntry, "(cn="...

Split a string (on whitespace or punctuation) to get all numbers

python,regex,findall

Instead of splitting the string, why not just get the numbers directly: >>> import re >>> Mystring = "123 456 789, 234, 999|567 888[222" >>> re.findall('\d+', Mystring) ['123', '456', '789', '234', '999', '567', '888', '222'] >>> \d+ has Python match one or more digits (a number)....

findAll on non object in extbase

repository,extbase,findall,typo3-4.5

This has something to do with the object and reflection caching in Extbase. In TYPO3 4.5 you should truncate manually all cache related tables in your database. I guess the related tables for the Extbase object and reflection caching are cf_extbase_object, cf_extbase_object_tags, bcf_extbase_reflection and cf_extbase_reflection_tags but I'm not sure. In...

Regex separate urls in text that has no separators

python,regex,url,findall

You need to use a positive lookahead assertion. >>> s = "https://00e9e64bac25fa94607-apidata.googleusercontent.com/download/redacted?qk=AD5uMEnaGx-JIkLyJmEF7IjjU8bQfv_hZTkH_KOeaGZySsQCmdSPZEPHHAzUaUkcDAOZghttps://console.developers.google.com/project/reducted/?authuser=1\n" >>> re.findall(r'https?://.*?(?=https?://|$|\s)', s) ['https://00e9e64bac25fa94607-apidata.googleusercontent.com/download/redacted?qk=AD5uMEnaGx-JIkLyJmEF7IjjU8bQfv_hZTkH_KOeaGZySsQCmdSPZEPHHAzUaUkcDAOZg',...

Catch multiple string occurrences in multiline text

python,regex,string,findall

This works: >>> txt='''\ ... RX[0] ... qpn : 0x48 ... cqn : 0x80 ... rxBytes : 179531811 ... rxPackets : 296242 ... rxPacketsDropped : 0 ... rxCheckSumOk : 225257 ... rxCheckSumNone : 200 ... RX[1] ... qpn : 0x49 ... cqn : 0x81 ... rxBytes : 0 ... rxPackets...

Regular expression OR in python findall

python,regex,findall

The parenthesis you are using tells findall() to match the pattern and give you back only the contents of the parenthesis. Using ?: you are matching the pattern as previously, but instead you get the whole match. re.findall("void (?:D|S)TC_.+\(\)", testCaseFile) ...

Symfony2 Entity findAll()

symfony2,doctrine,findall

@ORM\Id means values of this field MUST be unique. With the boolean type they can be unique only in 2 or less row (because boolean has only 2 values - 0 and 1). I think you have logical mistake, and must simply change type of field to integer. Like that:...

Regex for extracting name starting with Mr.|Mrs

python,regex,findall

Change your regex like below, (?:Mr\.|Mrs\.) [a-zA-Z]+ DEMO You need to put Mr\., Mrs\. inside a non-capturing or capturing group , so that the | (OR) applies to the group itself. You must need to escape the dot in your regex to match a literal dot or otherwise, it would...