string extraction

E

Etayki

Hi!

I am having this problem.

I have two strings:
(e-mail address removed)
(e-mail address removed)

I want a general expression that will extract the following from the
two strings above:
co.au
gov.uk

Does anyone know of how to do this in a few lines of code using
regular expressions?

Thanks for all the help,

Etay
 
M

Marina Levit[MVP]

If you just need everything after the @ sign, do you need a regular
expression? Just find the index of the @ sign, and get the rest of the
string that follows.
 
M

Marco Trapanese

Etayki said:
Hi!

I am having this problem.

I have two strings:
(e-mail address removed)
(e-mail address removed)

I want a general expression that will extract the following from the
two strings above:
co.au
gov.uk

Does anyone know of how to do this in a few lines of code using
regular expressions?

Without regular expressions you might find the position of the first dot
after the 'at' sign.

Bye
Marco / iw2nzm
 
N

NetworkElf

Marco Trapanese said:
Without regular expressions you might find the position of the first dot
after the 'at' sign.

Bye
Marco / iw2nzm

Actually, wouldn't it be the 2nd dot from the right?

In this case: something.someplace.co.uk, the 1st dot after the @ would
return someplace.co.uk.

Though, on the off chance that someone is really sticking to the rules
(doubtful, but always possible), if there's a trailing dot, it should be
found and dropped first.
 
M

Marco Trapanese

NetworkElf said:
In this case: something.someplace.co.uk, the 1st dot after the @ would
return someplace.co.uk.

Though, on the off chance that someone is really sticking to the rules
(doubtful, but always possible), if there's a trailing dot, it should be
found and dropped first.


mmm... but in this other case: @libero.it the second dot doesn't exist
at all!

Marco / iw2nzm
 
N

NetworkElf

Marco Trapanese said:
mmm... but in this other case: @libero.it the second dot doesn't exist at
all!

Based on the OP's requirement:


@libero.it doesn't seem to fit the proposed model. Or am I missing
something?

ne.
 
M

Marco Trapanese

NetworkElf said:
Based on the OP's requirement:
[cut]

@libero.it doesn't seem to fit the proposed model. Or am I missing
something?

Well then:
In this case: something.someplace.co.uk, the 1st dot after the @ would
return someplace.co.uk.

is different from the proposed model too! :)

Marco / iw2nzm
 
G

Guest

Just answering your question:
Dim regex As System.Text.RegularExpressions.Regex
regex = New System.Text.RegularExpressions.Regex("\w+.\w+@\w+.")
MsgBox (regex.Replace("(e-mail address removed)", ""))
Hope this help for you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top