Class RegexSelector

  • All Implemented Interfaces:
    Selector

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

      Constructors 
      Constructor Description
      RegexSelector​(java.lang.String regexStr)
      Create a RegexSelector.
      RegexSelector​(java.lang.String regexStr, int group)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String select​(java.lang.String text)
      Extract single result in text.
      If there are more than one result, only the first will be chosen.
      us.codecraft.webmagic.selector.RegexResult selectGroup​(java.lang.String text)  
      java.util.List<us.codecraft.webmagic.selector.RegexResult> selectGroupList​(java.lang.String text)  
      java.util.List<java.lang.String> selectList​(java.lang.String text)
      Extract all results in text.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RegexSelector

        public RegexSelector​(java.lang.String regexStr,
                             int group)
      • RegexSelector

        public RegexSelector​(java.lang.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 Detail

      • select

        public java.lang.String select​(java.lang.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 java.util.List<java.lang.String> selectList​(java.lang.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​(java.lang.String text)
      • selectGroupList

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object