Hi, I am trying to construct a regular expression to search and replace a file. The following is the script.
#!use/bin/perl
use strict;
use warnings;
my $line = $ARGV[0];
my $find = "[^a-zA-Z0-9]+seqfile[^a-zA-Z0-9]+=[^a-zA-Z0-9]+[a-z]+..";
my $replace = "done"; open (FILE, ">>/home/user/Desktop/test") || die "cant open file \n"; ...
For the love of God I am not getting this easy code to work! It is always alerting out "null" which means that the string does not match the expression.
var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$";
function isEmailAddress(str) {
str = "[email protected]";
alert(str.match(pattern));
return str.match(pattern...
Hello.
I have a python template engine that heavily uses regexp. It's uses concatenation like
re.compile( regexp1 + "|" + regexp2 + "*|" + regexp3 + "+" )
I can modify individual substrings (regexp1, regexp2 etc). Is it any small and light expression that match nothing so i can use it inside a template where i don't want any matches...
How can I match everything with a PHP regular expression? I tried: /[.\r\n]*/, but it isn't working. Any ideas? Thanks.
This is for a method I made for a PHP class to parse e-mails:
public function getHeader($headerName) {
preg_match('/[\r\n]' . $headerName . '[:][ ](.+)[\r\n][^ \t]/Uis', "\n" . ltrim($this->originalMessage), ...
Been trying to solve this for a while now.
I need a regex to strip the newlines, tabs and spaces between the html tags demonstrated in the example below:
Source:
<html>
<head>
<title>
Some title
</title>
</head>
</html>
Wanted result:
<html><head><title>Some title</title></head></html>
The trimming o...
I've been parsing poker hand histories for the past year and have learned quite a deal about parsing in general.
We started with regexes but quickly realized that wouldn't scale easily.
We skipped languages from ruby to c++ and finally came to grips that it was the algorithim that had to change.
We picked up Boost::Spirit and watched o...
I'm doing a simple search-and-replace in Perl, but I need some help. These are lines in a file:
1001(seperator could be "anything")john-1001(seperator could be "anything")mark
1001(seperator could be "anything")mark-1001(seperator could be "anything")john
I wanna assign a new userID for john, like 2001. So this is the result I want:...
I am saving user-submitted HTML (in a database). I must prevent Javascript injection attacks. The most pernicious I have seen is the script in a style="expression(...)".
In addition to this, a fair amount of valid user content will include special characters and XML constructs, so I'd like to avoid a white-list approach if possible. (L...
Hello,
I'd like to be able to parse date and times out of a log file. Currently they're in the following format:
"02/Jun/2009:14:38:50" but i'd like to separate them in different columns using something available from a linux command line so that the resulting output looks as follows:
"02/Jun/2009" "14:38:50"
could someone please sh...
Alright, here's my current test function:
function make_void( str )
{
var str_arr = str.split( /[\W]+/ );
var voidstr;
var newstr = "";
for ( var i = 0; i < str_arr.length; i++ )
{
voidstr = str_arr[i];
// if ( Math.random() <= 0.9 )
// {
voidstr = voidstr.replace( /\w/gi, "?" );
// }
newstr += voidstr + " ";
}
do...
Hello,
I need some Regular expression experts for an extra hand. :)
I have different paths,different folders,different amount of folders.
My question:How do I get the last thing - the filename?
For example in the path:
C:\a\b\c\d\e\fgh.ddj
How do I get "fgh.ddj" with regular expressions?
...
code:
<span>Upload Adobe Acrobat file<img src="../../Images/UI/pdf.jpg" style="height: 25;
width: 20" height="25" width="20" /></span>
<asp:FileUpload ID="uplPdf" runat="server" />
<asp:RegularExpressionValidator ID="valPdf" runat="server" ErrorMessage="Only PDF files are allowed!"
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\...
Ok, i'm a regex doofus. I only ever learn enough to get me by, but i would like to know how to do the below regex without using a php ternary operator in the middle of it. Also it may be ugly but it works...
'^". $date[0].(($date[0] == 0)?'?':'').$date[1]."[/.-]".$date[2].(($date[2] == 0)?'?':'').$date[3]."'";
uhm. as you can see im u...
I want to get only function prototypes like
int my_func(char, int, float)
void my_func1(void)
my_func2()
from C files using regex and python.
Here is my regex format: ".*\(.*|[\r\n]\)\n"
...
How can I use SciTE to match a word character between 1 and 7 times?
normally it would be
\w{1,7}
...
Is it possible to detect repeated number patterns with a regular expression?
So for example, if I had the following string "034503450345", would it be possible to match the repeated sequence 0345? I have a feeling this is beyond the scope of regex, but I thought I would ask here anyway to see if I have missed something.
...
I need a regex to do the following (unfortunately it has to be a regex, I can't code this because it's working within a purchased product):
I'd like to select all image tags in a chunk of html where either the image tag does not contain a class attribute, or, if it does contain a class attribute, that attribute does not contain a specif...
class person {
var $name;
var $email;
//Getters
function get_name() { return $this->name; }
function get_email() { return $this->email; }
//Setters
function set_name( $name ) { $this->name = $name; }
function set_email( $email ) {
if ( !eregi("^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,...
Given the pattern ^[a-zA-Z0-9 .\-_]+$ and the string te\\st, why is the match positive? I'm using this to validate usernames and I don't want people to put slashes in their usernames, it messes with URLs.
I'm calling ereg($pattern, $username), running PHP version 5.2.8.
...
I would like to convert a string into floating numbers. For example
152.15 x 12.34 x 11mm
into
152.15, 12.34 and 11
and store in an array such that $dim[0]=152.15, $dim[1]=12.34, $dim[2]=11.
I would also need to handle things like
152.15x12.34x11 mm
152.15mmx12.34mm x 11mm
Thank you.
...