Need Grouping of Regular Expression

Muhammad Muazzam

I want to get regex for the following construct where it should result as:

Actions and Sci-Fi

<a href="/?genre=Action">Actions</a> <a href="/?genre=Sci-Fi">Sci-Fi</a>
Avinash Raj

Don't parse html files with regex. If you insist then you could use the below regex and get the text inside anchor tags from group index 1.

<a\s[^<>]*>([^<>]*)<\/a>

DEMO

Explanation:

<a                       '<a'
\s                       whitespace (\n, \r, \t, \f, and " ")
[^<>]*                   any character except: '<', '>' (0 or more
                         times)
>                        '>'
(                        group and capture to \1:
  [^<>]*                   any character except: '<', '>' (0 or
                           more times)
)                        end of \1
<                        '<'
\/                       '/'
a>                       'a>'

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Regular expression for arithmetic expression

来自分类Dev

Regular Expression for SFTP URL

来自分类Dev

Understanding Regular Expression in Javascript

来自分类Dev

Regular expression for price validation

来自分类Dev

Java regular expression replaceall

来自分类Dev

Perl: Regular Expression

来自分类Dev

Invalid regular expression: /(/: Unterminated group

来自分类Dev

Regular expression that ignores certain characters

来自分类Dev

Regular expression route constraint for a resource route

来自分类Dev

R, regular expression for everything before nth occurrence

来自分类Dev

A multi-line, variedly greedy, regular expression

来自分类Dev

How to delete columns with regular expression for the header in R

来自分类Dev

Regular Expression Letter followed by numbers or numbers and a letter

来自分类Dev

Regular expression to keep a running count of individual characters

来自分类Dev

retrieve a word after a regular expression in shell script

来自分类Dev

PHP regular expression syntax for word phrase?

来自分类Dev

How to pass a regular expression to a function in AWK

来自分类Dev

Regular Expression for dd-MMM-yy

来自分类Dev

regular expression to match everything until the last occurrence of /

来自分类Dev

How to express "Not this character including boundary" in a regular expression?

来自分类Dev

CMake中的PASS_REGULAR_EXPRESSION

来自分类Dev

comparing two strings using perl regular expression

来自分类Dev

Regular expression to extract Section Number and Description

来自分类Dev

与regular_expression有关的问题

来自分类Dev

regular expression to extract any word not (single|double) quote delimited

来自分类Dev

CMake的PASS_REGULAR_EXPRESSION如何匹配多行输出?

来自分类Dev

Regular expression having white spaces only between two strings

来自分类Dev

Ruby one-liner to capture regular expression matches

来自分类Dev

Regular expression *this close*, but still missing one type of symbol

Related 相关文章

  1. 1

    Regular expression for arithmetic expression

  2. 2

    Regular Expression for SFTP URL

  3. 3

    Understanding Regular Expression in Javascript

  4. 4

    Regular expression for price validation

  5. 5

    Java regular expression replaceall

  6. 6

    Perl: Regular Expression

  7. 7

    Invalid regular expression: /(/: Unterminated group

  8. 8

    Regular expression that ignores certain characters

  9. 9

    Regular expression route constraint for a resource route

  10. 10

    R, regular expression for everything before nth occurrence

  11. 11

    A multi-line, variedly greedy, regular expression

  12. 12

    How to delete columns with regular expression for the header in R

  13. 13

    Regular Expression Letter followed by numbers or numbers and a letter

  14. 14

    Regular expression to keep a running count of individual characters

  15. 15

    retrieve a word after a regular expression in shell script

  16. 16

    PHP regular expression syntax for word phrase?

  17. 17

    How to pass a regular expression to a function in AWK

  18. 18

    Regular Expression for dd-MMM-yy

  19. 19

    regular expression to match everything until the last occurrence of /

  20. 20

    How to express "Not this character including boundary" in a regular expression?

  21. 21

    CMake中的PASS_REGULAR_EXPRESSION

  22. 22

    comparing two strings using perl regular expression

  23. 23

    Regular expression to extract Section Number and Description

  24. 24

    与regular_expression有关的问题

  25. 25

    regular expression to extract any word not (single|double) quote delimited

  26. 26

    CMake的PASS_REGULAR_EXPRESSION如何匹配多行输出?

  27. 27

    Regular expression having white spaces only between two strings

  28. 28

    Ruby one-liner to capture regular expression matches

  29. 29

    Regular expression *this close*, but still missing one type of symbol

热门标签

归档