Using C, I'm trying to find the location and number of matches of a substring within another parent string. Because I also need to include approximate (hamming distance) matches, I'm using the tre library found here: http://laurikari.net/tre/.
I'm having trouble understanding some of the documentation on the site, likely because I'm no...
I currently have a string which contains the characters A, B and C for example the string looks like
"A some other random stuff B C"
the other random stuff doesn't contain A, B or C I want to replace the A, B & C with 'A', 'B' and 'C' respectively what's the best way to do that currently I'm doing:
String.replace("A", "'A'").replace...
Hi, I am trying to remove text that is within parentheses (along with the parentheses themselves) but am having trouble with the scenario where there are parentheses within parentheses. This is the method I am using (in Ruby):
sentence.gsub(/\(.*?\)/, "")
and that works fine until I have a sentence such as:
"This is (a test (strin...
Hi all,
i am searching for latitude and and longitude validation.
can any one suggest that validation.
i am using
if (Regex.IsMatch(textBox1.Text, "\b(?(?:90|(?:[0-8]?\\d))([ -/])[0-5]?\\d\\1[0-5]?\\d(\\.\\d{1,4})?\\1[NS])\b") == true)
Thanks to all.
...
Hi Guys,
I need to match some chinese character in a utf8 encoded html , and I wrote some test code as below :
#! /usr/bin/perl
use strict;
use LWP::UserAgent;
use Encode;
my $ua = new LWP::UserAgent;
my $request = HTTP::Request->new('GET');
my $url = 'http://www.boc.cn/sourcedb/whpj/';
$request->url($url);
my $res = $ua->request($...
Hello,
I am having problems with an optional group in a regex (.NET syntax, and I'm using RegexOptions.Singleline).
"function (\w*).*?{(?:.*?\((.*?)\))?.*?}"
Also tried, to no avail:
"function (\w*)[^{]+{(?:.*?\((.*?)\))?.*?}"
It looks like the group is not optional, because if I just add two parenthesis in FunctionWithNoParameters ...
The thing I want to achieve with the code below: match a specified word case-insensitive and only once in a text and replace it with a link.
I have the following preg_match to match the word 'foo' in a string:
if (preg_match("/\bfoo\b/i", $text, $results, PREG_OFFSET_CAPTURE)) {
// substr_replace the word 'foo' for a link <a href.. ...
Hi,
I need to filter log messages based on the log level and a text appearing in the log message. These messages are in the following form:
12/23/2009 17:33:26.379 [INFO] TMSNG.Main Channelset configured with url [http://172.16.34.4:8080/tms-flux/messagebroker/streamingamf]
12/23/2009 17:33:26.380 [DEBUG] org.springextensions....
I've been able to stumble my way through regular expressions for quite some time, but alas, I cannot help a friend in need.
My "friend" is trying to match all lines in a text file that match the following criteria:
Only a 7 to 10 digit number (0123456 or 0123456789)
Only a 7 to 10 digit number, then a dash, then another two digits (01...
How does one "parameterize" variable input into a Regex in Ruby? For example, I'm doing the following:
q = params[:q]
all_values.collect { | col | [col.name] if col.name =~ /(\W|^)#{q}/i }.compact
Since it (#{q}) is a variable from an untrusted source (the query string), I have to assume it could be an attack vector. Any best practice...
I'm trying to write a simple program that will compare the files in separate folders. I'm currently using LINQ to Objects to parse the folder and would like to included information extracted from the string in my result set as well.
Here's what I have so far:
FileInfo[] fileList = new DirectoryInfo(@"G:\Norton Backups").GetFiles();
v...
The Ruby in Tim Bray's Wide Finder benchmark (http://wikis.sun.com/display/WideFinder/The+Benchmark) has this line:
%r{GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/[^ .]+) }
I've been using regexes for a long time, but I'm not sure what the point of the "." is. It seems to match on anything that's not a space, but [^ ] would do that...
I've already looked at this, which was helpful to a point.
Here's the problem. I have a list of users propagated into an element via user click; something like this:
<div id="box">
joe-user
page-joe-user
someone-else
page-someone-else
</div>
On click, I want to make sure that the user has not already been clicked into...
Sample text: String -> content within the rev tag (via lxml).
I'm trying to remove the {{BLOCKS}} within the text.
I've used the following regex to remove simple, one line blocks:
p = re.compile('\{\{*.*\}\}')
nonBracketedString = p.sub('', bracketedString)
However this does not remove the first multi line bracketed section at the b...
How to remove More Than One Spaces In Between Words of contents in dreamweaver source view. when i copy any data from MS word and paste in Dreaweaver. dreamweaver shows many unneeded spaces in source code. which is showing also in html output like extra space betwwen word and extra space after "." fullstop.
...
I want to replace empty lines in my string with an iterating number
e.g.
replace
String:
"My first line
My second line
My third line"
with
"
1
My first line
2
My second line
3
My third line"
I can match and replace these lines using
var newstring = TestVar.replace (/(^|\n\n)/g, "\nhello\n");
However I'm struggling to ad...
Hello,
this is how my table looks:
key | driver | machine | result
-----------------------------------
1 | 1234 | abc_machine | pass
2 | 1234 | xyz_machine | fail
when a user selects '1234' from driver and all from machine things get a little messy. (user makes selection from a gui)
when i do:
$getConfig = `sqlite3 ...
hi
I want a regex pattern to check that the string doesn't contain any digits .
For Illustration :
I'm coding a Hospital System and I want from user to enter the name of the patient , Of course the name shouldn't contain any digits , how can I do this by Regex ?
...
I am busy with an application that uses transclusion. Basically I need to parse a given text and capture tags as follows:
{{author: name |
book : sometitle |
year : someyear |
img : {{img:.....}}
}}
My problem is that I need to recursively parse what is within the double curly brackets and replace it with other text. ...
Hey and happy holidays
I'm working in ruby on rails and need the following:
remove all "br" html tags between "code" html tags in a string of html. The "code" tags might occur more than once.
Now, it's not screen scrapping I'm trying to do. I have a blog and would like to allow people to use the code html tags only in the comments. S...