Greater than and less than symbol in regular expressions

badu

I am new to regular expressions, and I am just tired by really studying all of the regex charatcer and all. I need to know what is the purpose of greater than symbol in regex for eg:

preg_match('/(?<=<).*?(?=>)/', 'sadfas<[email protected]>', $email);

Please tell me the use of greater than symbo and less than symbol in regex.

Boris the Spider

The greater than symbol simply matches the literal > at the end of your target string.

The less than symbol is not so simple. First let's review the lookaround syntax:

The pattern (?<={pattern}) is a positive lookbehind assertion, it tests whether the currently matched string is preceded by a string matching {pattern}.

The pattern (?={pattern}) is a positive lookahead assertion, it tests whether the currently matched string is followed by a string matching {pattern}.

So breaking down your expression

  • (?<=<) assert that the currently matched string is preceded by a literal <
  • .*? match anything zero or more times, lazily
  • (?=>) assert than the currently matched string is followed by a literal >

Putting it all together the pattern will extract [email protected] from the input string you have given it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Greater than and less than symbol in regular expressions

From Dev

Excel - Treat Greater Than or Less Than Symbol as part of Text Criteria

From Dev

Excel - Treat Greater Than or Less Than Symbol as part of Text Criteria

From Dev

Regex match greater than or less than symbol followed by any numbers

From Dev

Regular expression for percentages greater than 0 and less than or equal to 100

From Dev

Greater Than and Less Than Symbols in C# Regular Expression

From Dev

Greater than or Less than equal to

From Dev

if greater than or less than and zero

From Dev

How can I use a greater than or less than symbol with a python script embedded in xml?

From Dev

If value is greater than, less than and becomes greater than again

From Dev

If value is greater than, less than and becomes greater than again

From Dev

Python Less/Greater than issue

From Dev

greater than and less than equals to in sql?

From Dev

Creating a greater than but less than function in XML

From Dev

Strange Greater than or Less than Results

From Dev

Greater than, Less than string Lua (Lapis)

From Dev

Using '/' as greater than less than in Python?

From Dev

Javascript diamond? (Less than followed by greater than)

From Dev

Is there a greater than but less than function in python?

From Dev

AppleScript less than number or greater than number

From Dev

Regex that detects greater than ">" and less than "<" in a string

From Dev

SQL Server - Dates, Greater than and Less than

From Dev

Returning greater than and less than values in pandas

From Dev

Greater than and Less than Value SSRS 2008

From Dev

greater than and less than equals to in sql?

From Dev

Strange Greater than or Less than Results

From Dev

Python greater than and less than operands not working?

From Dev

Use R switch for less than or greater than?

From Dev

.NET Greater than/less than not working

Related Related

  1. 1

    Greater than and less than symbol in regular expressions

  2. 2

    Excel - Treat Greater Than or Less Than Symbol as part of Text Criteria

  3. 3

    Excel - Treat Greater Than or Less Than Symbol as part of Text Criteria

  4. 4

    Regex match greater than or less than symbol followed by any numbers

  5. 5

    Regular expression for percentages greater than 0 and less than or equal to 100

  6. 6

    Greater Than and Less Than Symbols in C# Regular Expression

  7. 7

    Greater than or Less than equal to

  8. 8

    if greater than or less than and zero

  9. 9

    How can I use a greater than or less than symbol with a python script embedded in xml?

  10. 10

    If value is greater than, less than and becomes greater than again

  11. 11

    If value is greater than, less than and becomes greater than again

  12. 12

    Python Less/Greater than issue

  13. 13

    greater than and less than equals to in sql?

  14. 14

    Creating a greater than but less than function in XML

  15. 15

    Strange Greater than or Less than Results

  16. 16

    Greater than, Less than string Lua (Lapis)

  17. 17

    Using '/' as greater than less than in Python?

  18. 18

    Javascript diamond? (Less than followed by greater than)

  19. 19

    Is there a greater than but less than function in python?

  20. 20

    AppleScript less than number or greater than number

  21. 21

    Regex that detects greater than ">" and less than "<" in a string

  22. 22

    SQL Server - Dates, Greater than and Less than

  23. 23

    Returning greater than and less than values in pandas

  24. 24

    Greater than and Less than Value SSRS 2008

  25. 25

    greater than and less than equals to in sql?

  26. 26

    Strange Greater than or Less than Results

  27. 27

    Python greater than and less than operands not working?

  28. 28

    Use R switch for less than or greater than?

  29. 29

    .NET Greater than/less than not working

HotTag

Archive