Class RegexSelector

java.lang.Object
us.codecraft.webmagic.selector.RegexSelector
All Implemented Interfaces:
Selector

public class RegexSelector extends Object implements Selector
Selector in regex.
Since:
0.1.0
Author:
code4crafter@gmail.com
  • Constructor Details

    • RegexSelector

      public RegexSelector(String regexStr, int group)
    • RegexSelector

      public RegexSelector(String regexStr)
      Create a RegexSelector. When there is no capture group, the value is set to 0 else set to 1.
      Parameters:
      regexStr - the regular expression.
  • Method Details

    • select

      public String select(String text)
      Description copied from interface: Selector
      Extract single result in text.
      If there are more than one result, only the first will be chosen.
      Specified by:
      select in interface Selector
      Parameters:
      text - text
      Returns:
      result
    • selectList

      public List<String> selectList(String text)
      Description copied from interface: Selector
      Extract all results in text.
      Specified by:
      selectList in interface Selector
      Parameters:
      text - text
      Returns:
      results
    • selectGroup

      public us.codecraft.webmagic.selector.RegexResult selectGroup(String text)
    • selectGroupList

      public List<us.codecraft.webmagic.selector.RegexResult> selectGroupList(String text)
    • toString

      public String toString()
      Overrides:
      toString in class Object