What is the pythonic way to split a string before the occurrences of a given set of characters?
For example, I want to split
'TheLongAndWindingRoad'
at any occurrence of an uppercase letter (possibly except the first), and obtain
['The', 'Long', 'And', 'Winding', 'Road'].
Edit: It should also split single occurrences, i.e.
from 'ABC'...
I need to remove any instances of 544 full-text stopwords from a user-entered search string, then format it to run a partial match full-text search in boolean mode.
input: "new york city", output: "+york* +city*" ("new" is a stopword).
I have an ugly solution that works: explode the search string into an array of words, look up each w...
I have a form where the user can type something and I want my script to check if it's a sum (e.g. 5 x 5 or 3+ 3) how would I do this? Presumably using Regular Expressions?
...
I'd like to make a script where the user can enter a sum e.g. 4^5+(56+2)/3 or any other basic maths sum (no functions etc.) how would I go about doing this? Presumably regex. Could somebody point me in the right direction - I'm guessing this isn't going to be too easy so I'd just like some advice on where to start and I'll take it from...
I need to get all the numbers that start with #.
"this is sentence 1 . Item number #4567 "
"this is sentence 2. Item number #8937 and #6723"
I am using JavaScript.
Using regular expression how do I get all the numbers in a string.
...
I'm performing this on a string:
var poo = poo
.replace(/[%][<]/g, "'<")
.replace(/[>][%]/g, ">'")
.replace(/[%]\s*[+]/g, "'+")
.replace(/[+]\s*[%]/g, "+'");
Given the similar if these statements, can these regexs be comebined somehow?
...
I have the following in my .htaccess currently-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^go/([^/]*)/([0-9]+)/([0-9]+)/?$ http://foo.com/wp-content/plugins/foo/cloak.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
RewriteRule ^go/([^/]+)[/]?$ http://foo.com/wp-content/plugins/foo/cloak.php?name=$1&cloaked_url=$0 [...
Hi I am using c#.NET. I have created a regex validator to check for special characters means I donot want any special characters in username. The following is the code
Regex objAlphaPattern = new Regex(@"[[email protected]]");
bool sts = objAlphaPattern.IsMatch(username);
If I provide username as $%^&*asghf then the valid...
I have a django website running with mod_python and Apache. The current configuration directs all / traffic to the django site. Now, I need to enable userDir /~user on the machine as well. I have enabled the userDir module in Apache. Since, Apache is redirecting all the request to the django app, /~user is not working as the django just ...
I guess I'm getting really weak in logic.
I need to write a regular expression which matches everything except www. It should match wwwd, abcd and everything else, just not www. (Oh God, please, it shouldn't be very easy).
I'm using Ruby language's implementation of regular expression.
UPDATE: I need to use regular expression and not ...
I have this regular expression in c#:
Regex oRegex_ = new Regex("<!-- #BeginEditable \"Body\"[^>]*>(.*)<!-- #EndEditable [^>]*>", RegexOptions.Multiline);
MatchCollection matches_ = oRegex_.Matches(contents);
The variable called 'contents' equals this:
<!-- #BeginEditable "Body" -->First String<!-- #EndEditable --><!-- #BeginEditable...
I'd like to use PCRE to take a list of URI's and distill it.
Start:
http://abcd.tld/products/widget1
http://abcd.tld/products/widget2
http://abcd.tld/products/review
http://1234.tld/
Finish:
http://abcd.tld/products/widget1
http://1234.tld/
Any ideas, dear members of StackOverflow?
...
Hi,
I was using a regular expression for email formats which I thought was ok but the customer is complaining that the expression is too strict. So they have come back with the following requirement:
The email must contain an "@" symbol and end with either .xx or .xxx ie.(.nl or .com). They are happy with this to pass validation. I h...
I keeping having the problem trying to extract data using regex whereas my result is not what I wanted because there might be some newlines, spaces, html tags, etc in the string, but is there anyway to actually see what is in the string, the debugger seems to show only the real text. How do you deal with this?
...
I'm reading a file in Python that isn't well formatted, values are separated by multiple spaces and some tabs too so the lists returned has a lot of empty items, how do I remove/avoid those?
This is my current code:
import re
f = open('myfile.txt','r')
for line in f.readlines():
if re.search(r'\bDeposit', line):
print l...
Hey Guys,
I'm having problems creating a regular expression which will fix a valid string.
The string will be in the format:
any alpha-numerical character 3 to 5 times,
followed by a comma if there are more characters after
else its the end of the string
Example Strings:
A401,CR56,4U9Y,MO16,ECZGB,A7DC,9LN5,D52PU,UT95,YBPB0,2JWA,AAMW,K...
Every single flavor of regex I have ever used has always had the "." character match everything but a new line (\r or \n)... unless, of course, you enable the single-line flag.
So when I tried the following C# code I was shocked:
Regex rgx = new Regex(".");
if (rgx.Match("\r\n").Success)
MessageBox.Show("There is something rotten in ...
Hi,
I'm using excel 2007 and i'm adding a macro that looks something like this :
Function S(Value As String, Pattern As String, ReplaceWith As String, Optional IgnoreCase As Boolean = False)
Dim r As New VBScript_RegExp_55.RegExp
r.Pattern = Pattern
r.IgnoreCase = IgnoreCase
r.Global = True
S = r.Replace(Value, R...
I'm trying to write a regular expression using the PCRE library in PHP.
I need a regex to match only &, > and < chars that exist within string part of any XML node and not the tag declaration themselves.
Input XML:
<pnode>
<cnode>This string contains > and < and & chars.</cnode>
</pnode>
The idea is to to a search and replace thes...
Hi experts,
In the past I have asked this question.But somehow I did not give the complete input.Input is a log file. I am trying to use sed to replace all but last four digits of credi card number.
sed -e :a -e "s/[0-9]\([0-9]\{4\}\)/\*\1/;ta" $today_temp_log
This expression definitely works but it replaces not just Credit card numbe...