I would like some help to handle someones name string. I would like to take a string and delete it so that only the first name is in the string.
Suppose I have a name like this
Mr. John Doe John Smith.
In both cases, I would like to get only the first line name and delete all other characters.
So, for both lines after they have been analyzed, will have Johnin them
John
I was wondering if there is a way to make this problem with regex.
. , . John Paul Doe ( "John", "Paul", "Doe" ), John Joseph Brown ( "Joseph" "Joe", - "John" on ), ( " " ).
Go Falsenesss .
, , , 95% , . (80%, ).
, , , , "" , "Mr", - ( "Mr", , -, ).
s/^\s+//; s/\s+$//; # trim whitespace at each end s((\s+))( # trim embedded whitespace $1=~/[^\x{a0}]/ ? # breakable? " " : "\x{a0}")ge;
, $1.
^(?:Mr\.|Mrs\.)?\s*\b([^\s]*)\b.*$
, Regexr
,
/^(?:\w+\.)?\s*(\w+).*$/ // $1 = John
:\w+\. , ( )(\w+\.)? (?:\w+\.)? ( )^(?:\w+\.)? ^ ( ) ^(?:\w+\.)?\s* ( none)^(?:\w+\.)?\s*(\w+), ( ) ^(?:\w+\.)?\s*(\w+).*$ finally .* $
\w+\.
(\w+\.)?
(?:\w+\.)?
^(?:\w+\.)?
^(?:\w+\.)?\s*
^(?:\w+\.)?\s*(\w+)
^(?:\w+\.)?\s*(\w+).*$
.*
$
?
, :
/(?<=((Mr\.|Mrs\.)\s+)?)([a-zA-Z]+)/
my $nameFull = 'Mr. John Doe'; my $nameFirst = $1 if $nameFull =~ /(?:\s|^)(?!(?:mr|mr?s|miss|dr|prof)(?![a-z]))([a-z]+)/i;
:
/... /iThe beginning and end of a case-insensitive regular expression
/
/i
(?:\s|^)
(?!
)
(?:mr|mr?s|miss|dr|prof)
r?
r
Ms
Mrs
(?![a-z])
drake
dr
(
$1
[a-z]+