regex

regular expression for custom route element in cakephp

Here is my acutal link /news-wet/top-new/asd-def-jkl.html and i m using: Router::connect(‘/:newsroute/*’, array(‘controller’ => ‘article’, ‘action’ =>’articleDetails’),array(‘newsroute’=>’/news-[a-z]+/top-news/’)); this convention to redirect in cakephp routes.php file. in /news-wet/, wet string might be vary and last asd-def-jkl.html also vary.but it is not working. Source: regex

Using Perl to strip everything from a string except HTML Anchor Links

Using Perl, how can I use a regex to take a string that has random html in it with one html link with anchor, like this: <a href=”http://example.com” target=”_blank”>Whatever Example</a> and it leave ONLY that and get rid of everything else? No matter what was inside the href link with the <a, like title=, or style=, or whatever. and it…
Read more

MySQL regex – Get text in one query

Assume we have a table like this in MySQL tbl_test —————————————————– | ID | text | —————————————————– | 1 | Lorem ipsum n Teacher: Mr. Brown n Age: 43 | | 2 | Dolor n Teacher: Mrs. Morgan n Age: 35 | —————————————————– Is it possible to get the name of the teachers with one single SQL Query. The expected…
Read more

Trying to use Beautiful Soup (Python) to find 2 partial matches in an attribute’s value

(This is a follow-up question to a previous post, which user http://stackoverflow.com/users/771848/alecxe helped me with. Makes more sense to post this follow-up as an independent question though, so it is more searchable for others.) I have a python script using Beautiful Soup to locate some web reports on a hosting service. Right now the script is pretty exacting. I would…
Read more

Postgres : Select the maximum integer substring of a column value

I’m using postgresql and I’m having a trouble formulating the right sql query. The title of the question might sound weird, but it is exactly what I’m trying to achieve. I’m currently performing data curation with a particular table. If I have a table product containing : id | designation ——————— 1 | IR15A1021 2 | IR15A1001 3 | IR15A1050…
Read more

how to escape a whole sequence of characters?

I’m using the following code to “execute” a regular expression in mfc c++ std::wregex rx(regularExpression,nFlags); std::wcmatch res; std::regex_search(inputString, res, rx); This is used in a dialog where the user types in the regularExpression and I search it in my inputString. The user can also select to not use a regular expression and just search normal text, but I want to…
Read more

Postgresql regex to return multiple values

I have a scenario in postgres where I need to gather all entries between multiple sets of square brackets. The following example would be what I would expect to capture this: SELECT (regexp_matches(‘Hello [World] How [Are] You’,'[(.*?)]’)) But this simply returns {World} ignoring the second [Are] section. In a regular regex this seems to work, so I’m unsure as to…
Read more

JavaScript : Find (and Replace) text that is NOT in a specific HTML element?

TL;DR; Summary How do I inject a <span> around a specific word or phrase found in the HTML of the current page BUT ignore any text which is ALREADY contained within the same span I am trying to inject. Due to the large number of values being processed, this must be high performance! Example: Searching for “foo” Should find a…
Read more