3 6126
On Fri, 22 Aug 2003 10:46:22 -0400, danpres2k wrote: Hello, I have a file with email address at a lot of junk data. I want to get the email addresses out of that file so that each email address is stored at a new line. I am trying to do wo**@word.word substitution: $filestring=<FILE>; $filestring = s/(\w+\@\w+\.\w+)/\n$1\n/;
The file is like: "testin" kj*****@ksjdf.com, <testing>js****@ksjdf.com kj***@kjd.com "ks***@kdjk.com"
Expected output: kj*****@ksjdf.com js****@ksjdf.com kj***@kjd.com ks***@kdjk.com
Thanks guyz.
Two things:
1. Do you really want 2 newlines for each output?
2. Since the first regex is matching the e-mail address and
ONLY the e-mail address, you're actually telling the s/// to
search the entire string for an e-mail address and substitute
the e-mail address with itself, not, as you intend, to substitute
the entire string with itself. You want to add a .* after the closing
parenthesis, maybe.
Instead of: $filestring = s/(\w+\@\w+\.\w+)/\n$1\n/;
Try: $filestring = s/(\w+\@\w+\.\w+).*/\n$1\n/;
Or Possibly: $filestring = s/.*(\w+\@\w+\.\w+).*/\n$1\n/;
Untested, but I had a similar problem recently, and the
principle is the same.
Shawn
Shawn,
Thanks for your help. But I couldn't use that as well. I am getting
null value for $filestring when I am printing it:
$filestring = <FILE>;
$filestring = s/.*(\w+\@\w+\.\w+).*/$1/;
print $filestring;
Got any suggestion?
Thanks.
Shawn Milochik <Sh***@Linurati.net> wrote in message news:<pa*********************************@Linurati .net>... On Fri, 22 Aug 2003 10:46:22 -0400, danpres2k wrote:
Hello, I have a file with email address at a lot of junk data. I want to get the email addresses out of that file so that each email address is stored at a new line. I am trying to do wo**@word.word substitution: $filestring=<FILE>; $filestring = s/(\w+\@\w+\.\w+)/\n$1\n/;
The file is like: "testin" kj*****@ksjdf.com, <testing>js****@ksjdf.com kj***@kjd.com "ks***@kdjk.com"
Expected output: kj*****@ksjdf.com js****@ksjdf.com kj***@kjd.com ks***@kdjk.com
Thanks guyz.
Two things:
1. Do you really want 2 newlines for each output?
2. Since the first regex is matching the e-mail address and ONLY the e-mail address, you're actually telling the s/// to search the entire string for an e-mail address and substitute the e-mail address with itself, not, as you intend, to substitute the entire string with itself. You want to add a .* after the closing parenthesis, maybe.
Instead of: $filestring = s/(\w+\@\w+\.\w+)/\n$1\n/;
Try: $filestring = s/(\w+\@\w+\.\w+).*/\n$1\n/;
Or Possibly: $filestring = s/.*(\w+\@\w+\.\w+).*/\n$1\n/;
Untested, but I had a similar problem recently, and the principle is the same.
Shawn
Thanks again Shawn, It did work but only printed a part of the last
email in the first line. how do i go about the newline chars in the
$filestring? i am storing the string from the file handle in
$filestring. is this correct?
thanks.
d
Shawn Milochik <Sh***@Linurati.net> wrote in message news:<pa*********************************@Linurati .net>... On Fri, 22 Aug 2003 16:57:00 -0400, danpres2k wrote:
Shawn,
Thanks for your help. But I couldn't use that as well. I am getting null value for $filestring when I am printing it:
$filestring = <FILE>; $filestring = s/.*(\w+\@\w+\.\w+).*/$1/; print $filestring;
Got any suggestion? Thanks.
Shawn Milochik <Sh***@Linurati.net> wrote in message news:<pa*********************************@Linurati .net>... On Fri, 22 Aug 2003 10:46:22 -0400, danpres2k wrote:
> Hello, I have a file with email address at a lot of junk data. I want > to get the email addresses out of that file so that each email > address is stored at a new line. I am trying to do wo**@word.word > substitution: $filestring=<FILE>; > $filestring = s/(\w+\@\w+\.\w+)/\n$1\n/; > > The file is like: > "testin" kj*****@ksjdf.com, <testing>js****@ksjdf.com kj***@kjd.com > "ks***@kdjk.com" > > Expected output: > kj*****@ksjdf.com > js****@ksjdf.com > kj***@kjd.com > ks***@kdjk.com > > Thanks guyz.
Two things:
1. Do you really want 2 newlines for each output?
2. Since the first regex is matching the e-mail address and ONLY the e-mail address, you're actually telling the s/// to search the entire string for an e-mail address and substitute the e-mail address with itself, not, as you intend, to substitute the entire string with itself. You want to add a .* after the closing parenthesis, maybe.
Instead of: > $filestring = s/(\w+\@\w+\.\w+)/\n$1\n/;
Try: > $filestring = s/(\w+\@\w+\.\w+).*/\n$1\n/;
Or Possibly: > $filestring = s/.*(\w+\@\w+\.\w+).*/\n$1\n/;
Untested, but I had a similar problem recently, and the principle is the same.
Shawn
Yeah, just a typo. Replace = with: =~
I didn't catch that in the OP.
Shawn This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: NimP |
last post by:
Hi,. I'm trying to detect any links that are contained within an html page
using eregi pattern matching. I was wondering if there are any pattern
matching geniuses out there who could write a...
|
by: gsv2com |
last post by:
One of my weaknesses has always been pattern matching. Something I
definitely need to study up on and maybe you guys can give me a pointer
here.
I'm looking to remove all of this code and just...
|
by: Thomas Reichelt |
last post by:
Moin,
short question: is there any language combining the syntax, flexibility and
great programming experience of Python with static typing? Is there a
project to add static typing to Python?
...
|
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# Matching string patterns
#
# Sometimes you want to know if a string is of
# particular pattern. Let's say in your website
# you have converted all images...
|
by: Henry |
last post by:
I have a table that stores a list of zip codes using a varchar column type,
and I need to perform some string prefix pattern matching search. Let's say
that I have the columns:
94000-1235
94001...
|
by: bpontius |
last post by:
The GES Algorithm
A Surprisingly Simple Algorithm for Parallel Pattern Matching
"Partially because the best algorithms presented in the literature
are difficult to understand and to implement,...
|
by: olaufr |
last post by:
Hi,
I'd need to perform simple pattern matching within a string using a
list of possible patterns. For example, I want to know if the substring
starting at position n matches any of the string I...
|
by: Ole Nielsby |
last post by:
First, bear with my xpost. This goes to
comp.lang.c++
comp.lang.functional
with follow-up to comp.lang.c++
- I want to discuss an aspect of using C++ to implement a
functional language, and...
|
by: konrad Krupa |
last post by:
This message is a continuation of my previous post "Pattern Match"
Doug - Thank you for your help.
Doug Semler was able to solve my problem to some point but I still need some
help.
Doug's...
|
by: Peted |
last post by:
Hi,
im having some trouble with reg expression pattern matching for
something i think should be a straightforward test.
Im validating the text being entered in a winforms textbox and i need...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |