Hello friends,
I am new to Regex engine. I use Expresso to test RE. For a named
capturing test, I have following schema--
FullName --first , surname OR
FullName --surname , first , middle
eg. "advait raut" should return: first=advait surname=raut
and "raut advait mohan" should return: first=advait middle=mohan
surname=raut
For this I useed following RE.
^
(((<?first>[a-z]+)\s(<?surname>[a-z]+))|((<?surname>[a-z]+)\s(<?
first>[a-z]+)\s(<?middle>[a-z]+)))
$
But I dont get the valid match. Where am I mistaking ?
yours
Advait 2 1718
Advait,
Assuming that Fullname could be written the way given below
FullName --first , surname OR
FullName --surname , first , middle
You could split the Fullname string separated by space.
If it returns 2 elements, it should be firstname, surname
If it returns 3 elements, it should have been surname, firstname,
middlename
Why bother using regexp for this?
Pardon me, if I don't understand your problem correctly.
Kalpesh
Kalpesh wrote:
Advait,
Assuming that Fullname could be written the way given below
FullName --first , surname OR
FullName --surname , first , middle
You could split the Fullname string separated by space.
Yes, I can use split but I will have to implement backtracking. It
would be better option if I have 4-5 clauses like here. But when I
have 20-30 clauses, I think Regex is better option. What do you
think ?
If it returns 2 elements, it should be firstname, surname
If it returns 3 elements, it should have been surname, firstname,
middlename
Yup, I also expect the same result but don't get it. Can anyone point
it out?
Why bother using regexp for this?
Pardon me, if I don't understand your problem correctly.
Kalpesh
yours
Advait This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrew Dixon |
last post by:
Hi Everyone.
Ok I have a problem getting the following regex to work in Java.
<script*>(.|\r|\n)+?</script>
It works fine in EditPad Pro but in Java it causes the following error
message...
|
by: Masahiro Ito |
last post by:
I have attached a block of text similar to the type that I am working
with.
I have been learning a lot about Regex - it is quite impressive. I can
easily capture bits of info, but I keep having...
|
by: Joerg Schuster |
last post by:
Hello,
Python regular expressions must not have more than 100 capturing
groups. The source code responsible for this reads as follows:
# XXX: <fl> get rid of this limitation!
if...
|
by: kevin |
last post by:
I am trying to strip the outermost html tag by capturing this tag with regex
and then using the string replace function to replace it with an empty
string. while stepping through the code, RegEx...
|
by: lgbjr |
last post by:
Hi All,
I'm trying to split a string on every character. The string happens to be a
representation of a hex number. So, my regex expression is ().
Seems simple, but for some reason, I'm not...
|
by: Mark |
last post by:
I must create a routine that finds tokens in small, arbitrary VB code
snippets. For example, it might have to find all occurrences of
{Formula}
I was thinking that using regular expressions...
|
by: Nightcrawler |
last post by:
Hi all,
I am trying to use regular expressions to parse out mp3 titles into
three different groups (artist, title and remix). I currently have
three ways to name a mp3 file:
Artist - Title ...
|
by: GS |
last post by:
How can one avoid capturing leading empty or blank lines?
the data I deal with look like this
"will be paid on the dates you specified.
xyz supplier
amount: $100.52 when: September 07,...
|
by: =?Utf-8?B?QWxCcnVBbg==?= |
last post by:
I have a regular expression for capturing all occurrences of words contained
between {{ and }} in a file. My problem is I need to capture what is between
those symbols. For instance, if I have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |