2

Hi I'm reading some code and found re.compile("<@(U\S+)>"), I'm having some trouble to understand the <>. Can someone give an example that matches? I have tried in python interactive shell with '<@U>' or '<@jyx>' and they do not match. Thanks.

1
  • 1
    \S+ means more than one none space character and it should come after <@U and before > like <@Ua> ;). Commented Jul 27, 2015 at 5:09

1 Answer 1

5

<> have no significance as such.

You have to provide <@U then 1 or more non space characters then > to match.

Like

<@UASD> <@US> 

Your input

<@U> did not match as no non space character present after U <@asd> did not match as no U present after @ 
Sign up to request clarification or add additional context in comments.

1 Comment

Just to clarify, you don't need a literal S to match this regex (your current examples both have an S, which could confuse someone). <@Under> is another example that will match this pattern.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.