SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    USA
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with pattern

    Hi All,

    I would like to match pattern - ",some.domain.name\user name". I tried using -
    PHP Code:
    ,\S{1}+\\S{1}+ 
    . But didn't work.

    Does anybody know the reason?

    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are we talking PHP or Perl?

    You talk about "match pattern" but what are you trying to achieve. Is it you are looking for a match with a particular pattern (,domain\username) or are you seeking to extract domain and username.

    I am weak on PHP but in perl something like

    my $thisstring = 'xxx,some.domain.name\username';
    print "true" if ($thisstring =~ m/,[^,]+\\[^,]+/);
    my ($domain, $username) = ($thisstring =~ m/,([^,]+)\\([^,]+)/);

    That is the string must start with a comma, then consist of two parts separated by a slash. The characters in the parts can not be a comma.

    I believe PHP is the same or very similar.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •