I need help i want to code a program that search for a word inside the source code.
Here a Example in Python:
import urllib2, re
site = "http://stackoverflow.com/"
tosearch = "Questions"
source = urllib2.urlopen(site).read()
if re.search(tosearch,source):
print "Found The Word", tosearch
...
Hi,
First question on here so please be nice :)
I know very little about regular expressions but I am using one in a current project which strips special characters from a string. It looks like this...
newWord = newWord.replace(/[^0-9A-Za-z ]/g, "");
It works well, but I need to modify it slightly so that it doesn't remove the £ (GB...
Is there any benefit in using compile for regular expressions in Python?
h = re.compile('hello')
h.match('hello world')
vs
re.match('hello', 'hello world')
...
Hi, The following code is visual basic, .NET, ASP... all of the above?
Can anybody tell me what these two "Regex.Replace" functions/methods will leave me with when "strCookies" is equal to the block of text below the two Regex.Replace functions? I believe the idea is simply to capture the "sessionid" code and then the "cadata" code with ...
So I'm trying to build a script that automagically prepends valid column names with its appropriate table prefix (e.g. "t." or "r.")
$t_columns = array('id', 'name', 'label');
$r_columns = array('related_value');
INPUT:
id > 1 AND (name = 'Hello' OR label IN ('World', 'Planet name AND label')) AND (related_value > 1 AND related_value...
Hi,
I am hopeless with regex (c#) so I would appreciate some help:
Basicaly I need to parse a text and I need to find the following information inside the text:
Sample text:
KeywordB:TextToFind the rest is not relevant but KeywordB: Text ToFindB and then some more text.
I need to find the word(s) after a certain keyword which may en...
I want to be able to run a regular expression on an entire file, but I'd like to be able to not have to read the whole file into memory at once as I may be working with rather large files in the future. Is there a way to do this? Thanks!
Clarification: I cannot read line-by-line because it can span multiple lines.
...
Given a regular expression, I'm looking for a package which will dynamically generate the code for a finite state machine that implements the RE.
C/C++ and Python preferred, but other languages are of interest as well.
...
I'm trying to split text in a JTextArea using a regex to split the String by \n However, this does not work and I also tried by \r\n|\r|n and many other combination of regexes.
Code:
public void insertUpdate(DocumentEvent e) {
String split[], docStr = null;
Document textAreaDoc = (Document)e.getDocument();
try {
doc...
Hi
I want to replace some HTML tags that I have in a CDATA element, but I struggle with getting the syntax in XSLT right. I am getting this error message:
net.sf.saxon.trans.XPathException: Error at character 9 in regular
expression "<img(\s+(?![^<>]*alt=["\'])[^<...": expected ()) (line 51)
I guess it does not like the <> inside th...
I try to find methods that have expression createNamedQuery
I try
public[\d\D]*?createNamedQuery
but it finds the first method, but i want the method that has expression createNamedQuery
...
I am trying to find all of the links in source code on a website, could anyone tell me the expression i would need to put in my Regex to find these?
Duplicate of (among others): Regular expression for parsing links from a webpage?
Google finds more: html links regex site:stackoverflow.com
...
I was playing around with Boost.Regex to parse strings for words and numbers. This is what I have so far:
#include <iostream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <boost/range.hpp>
using namespace std;
using namespace boost;
int main()
{
regex re
(
"("
"([a-z]+)...
I have I huge backup of posts of my blog. All posts has images like:
"http://www.mysite.com/nonono-nonono.jpg"
or
"http://www.mysite.com/nonono-nonono.gif"
or even
"http://www.mysite.com/nonono.jpg"
But I have other links for urls on the same domain like ""http://www.mysite.com/category/post.html" and I just want to replace urls...
I have a regular expression like this (much simplified):
^(ab)*$
And am matching against this:
abababababababab
When I run it through preg_match:
preg_match('/$(ab)*$/', 'abababababababab', $matches);
print_r($matches);
I get this:
Array
(
[0] => abababababababab
[1] => ab
)
Wheras I expect this:
Array
(
[0] => a...
I wonder if anyone can provide me with the regular expressions needed to parse a string like:
'foo bar "multiple word tag"'
into an array of tags like:
["foo","bar","multiple word tag"]
Thanks
...
I had a requirement where in the text field the first character should be a alpha numeric
and then i can allow a hyphen from thereafter in JavaScript.Also hyphen should not be allowed at the end
...
Hi.
I have an text that consists of information enclosed by a certain pattern.
The only thing I know is the pattern: "${template.start}" and ${template.end}
To keep it simple I will substitute ${template.start} and ${template.end} with "a" in the example.
So one entry in the text would be:
aINFORMATIONHEREa
I do not know how many o...
Hi,
I have a seemingly simple problem though i am unable to get my head around it.
Let's say i have the following string: 'abcabcabcabc' and i want to get the last occurrence of 'ab'. Is there a way i can do this without looping through all the other 'ab's from the beginning of the string?
I read about anchoring the end of the string ...
I am trying to do a regex match and replace for an .htaccess file but I can't quite figure out the replace bit. I think I have the match part right, but maybe someone can help.
I have this url-
http://www.foo.com/MountainCommunities/Lifestyles/5/VacationHomeRentals.aspx
And I'm trying to turn it into this-
http://www.foo.com/mountain-l...