This factory method will parse a line formed like:

Example:
RewriteCond %{REMOTE_HOST}  ^host1.*  [OR]

@param line
@return
351122
private static Object parse(String line) {
        StringTokenizer tokenizer = new StringTokenizer(line);
        if (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();
            if (token.equals("RewriteCond")) {
                // RewriteCond TestString CondPattern [Flags]
                RewriteCond condition = new RewriteCond();
                if (tokenizer.countTokens() < 2) {
                    throw UndertowServletLogger.ROOT_LOGGER.invalidRewriteConfiguration(line);
                }
                condition.setTestString(tokenizer.nextToken());
                condition.setCondPattern(tokenizer.nextToken());
                if (tokenizer.hasMoreTokens()) {
                    String flags = tokenizer.nextToken();
                    if (flags.startsWith("[") && flags.endsWith("]")) {
                        flags = flags.substring(1, flags.length() - 1);
                    }
                    StringTokenizer flagsTokenizer = new StringTokenizer(flags, ",");
                    while (flagsTokenizer.hasMoreElements()) {
                        parseCondFlag(line, condition, flagsTokenizer.nextToken());
                    }
                }
                return condition;
            } else if (token.equals("RewriteRule")) {
                // RewriteRule Pattern Substitution [Flags]
                RewriteRule rule = new RewriteRule();
                if (tokenizer.countTokens() < 2) {
                    throw UndertowServletLogger.ROOT_LOGGER.invalidRewriteConfiguration(line);
                }
                rule.setPatternString(tokenizer.nextToken());
                rule.setSubstitutionString(tokenizer.nextToken());
                if (tokenizer.hasMoreTokens()) {
                    String flags = tokenizer.nextToken();
                    if (flags.startsWith("[") && flags.endsWith("]")) {
                        flags = flags.substring(1, flags.length() - 1);
                    }
                    StringTokenizer flagsTokenizer = new StringTokenizer(flags, ",");
                    while (flagsTokenizer.hasMoreElements()) {
                        parseRuleFlag(line, rule, flagsTokenizer.nextToken());
                    }
                }
                return rule;
            } else if (token.equals("RewriteMap")) {
                // RewriteMap name rewriteMapClassName whateverOptionalParameterInWhateverFormat
                if (tokenizer.countTokens() < 2) {
                    throw UndertowServletLogger.ROOT_LOGGER.invalidRewriteConfiguration(line);
                }
                String name = tokenizer.nextToken();
                String rewriteMapClassName = tokenizer.nextToken();
                RewriteMap map = null;
                try {
                    map = (RewriteMap) (Class.forName(rewriteMapClassName).newInstance());
                } catch (Exception e) {
                    throw UndertowServletLogger.ROOT_LOGGER.invalidRewriteMap(rewriteMapClassName);
                }
                if (tokenizer.hasMoreTokens()) {
                    map.setParameters(tokenizer.nextToken());
                }
                Object[] result = new Object[2];
                result[0] = name;
                result[1] = map;
                return result;
            } else if (token.startsWith("#")) {
                // it's a comment, ignore it
            } else {
                throw UndertowServletLogger.ROOT_LOGGER.invalidRewriteConfiguration(line);
            }
        }
        return null;
    }
1218599
private String suffix(final String line) {
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if (c == ' ' || c == '\t') return line.substring(i + 1);
        }
        return "";
    }
477594
public Block split(final Line line)
    {
        final Block block = new Block();

        block.lines = this.lines;
        block.lineTail = line;
        this.lines = line.next;
        line.next = null;
        if (this.lines == null)
        {
            this.lineTail = null;
        }
        else
        {
            this.lines.previous = null;
        }

        if (this.blocks == null)
        {
            this.blocks = this.blockTail = block;
        }
        else
        {
            this.blockTail.next = block;
            this.blockTail = block;
        }

        return block;
    }
777899
def parse_line(self, line):
        """"""

        prefix = ""
        # ignore comma at start of lines
        if line.startswith(","):
            line, prefix = line[1:], ","

        j = json.loads(line)
        yield j
        self.io.write_line(prefix + json.dumps(j))
495589
public static CaptureSearchResult parseCDXLineFlex(String line) {
		CaptureSearchResult result = new CaptureSearchResult();
		return parseCDXLineFlex(line, result);
	}
941703
private ActionPatternHolder convertStringToPattern(String line) {
        ActionPatternHolder holder = new ActionPatternHolder();
        String[] strs = org.apache.commons.lang.StringUtils.split(line, "|");
        if (strs.length != 2) {
            throw new IllegalArgumentException("illegal expression: " + line);
        }
        Pattern compiledPattern;
        Perl5Compiler compiler = new Perl5Compiler();
        try {
            holder.setActionName(strs[0]);
            compiledPattern = compiler.compile(strs[0], Perl5Compiler.READ_ONLY_MASK);
            holder.setActionPattern(compiledPattern);
        } catch (MalformedPatternException mpe) {
            throw new IllegalArgumentException("Malformed regular expression: " + strs[0]);
        }

        try {
            holder.setMethodName(strs[1]);
            compiledPattern = compiler.compile(strs[1], Perl5Compiler.READ_ONLY_MASK);
            holder.setMethodPattern(compiledPattern);
        } catch (MalformedPatternException mpe) {
            throw new IllegalArgumentException("Malformed regular expression: " + strs[1]);
        }

        return holder;
    }
88171
public static List<String> splitString(String line, char delim) {
		return splitString(line, 0, line.length(), delim, new ArrayList<String>());
	}
8204
private IAtomContainer readSmiles(final String line) {
        try {
            return sp.parseSmiles(line);
        } catch (CDKException e) {
            logger.error("Error while reading the SMILES from: " + line + ", ", e);
            final IAtomContainer empty = builder.newInstance(IAtomContainer.class, 0, 0, 0, 0);
            empty.setProperty(BAD_SMILES_INPUT, line);
            return empty;
        }
    }
540807
private function parse($line)
    {
        $uriParser = new UriParser($line);
        $line = $uriParser->encode();
        if ($uriParser->validateIP() ||
            !$uriParser->validateHost() ||
            (
                parse_url($line, PHP_URL_SCHEME) !== null &&
                !$uriParser->validateScheme()
            )
        ) {
            return false;
        }
        $parts = $this->getParts($line);
        return $parts['scheme'] . $parts['host'] . $parts['port'];
    }
341772
def _line_parse(line):
    
    if line[-2:] in ["\r\n", b"\r\n"]:
        return line[:-2], True
    elif line[-1:] in ["\r", "\n", b"\r", b"\n"]:
        return line[:-1], True
    return line, False
320938
public static Stream<Quad> parseQuad(final String line) {
        final List<Token> tokens = new ArrayList<>();
        makeTokenizerString(line).forEachRemaining(tokens::add);

        final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull)
            .collect(toList());

        if (nodes.size() == 3) {
            return of(rdf.asQuad(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2))));
        } else if (nodes.size() == 4) {
            return of(rdf.asQuad(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2))));
        } else {
            LOGGER.warn("Skipping invalid data value: {}", line);
            return empty();
        }
    }
1249831
public IGPSObject parse(final String line) throws ParseException {
		try {
			final JSONObject json = new JSONObject(line);
			return this.parse(json);
		} catch (final JSONException e) {
			throw new ParseException("Parsing failed", e);
		}
	}
356169
public boolean supports(final String line) {
        final List<String> splits = new ArrayList<String>();
        int depth = 0;
        int textDepth = 0;
        boolean escape = false;
        StringBuffer split = new StringBuffer();
        for (char c : line.toCharArray()) {
            if (depth == 0 && c == '.') {
                splits.add(split.toString());
                split = new StringBuffer();
                depth = 0;
                textDepth = 0;
                escape = false;
                continue;
            } else if (c == '\\') {
                escape = true;
                split.append(c);
                continue;
            } else if (textDepth == 0 && c == '"') {
                textDepth++;
            } else if (!escape && textDepth > 0 && c == '"') {
                textDepth--;
            } else if (textDepth == 0 && c == '(') {
                depth++;
            } else if (textDepth == 0 && c == ')') {
                depth--;
            }
            split.append(c);
            escape = false;
        }
        splits.add(split.toString());
        return splits.size() == 2;
    }
825166
String[] splitFromInlineComment( String line ) {

		String[] result = new String[] { line, "" };
		int index = line.indexOf( ParsingConstants.COMMENT_DELIMITER );
		if( index >= 0 ) {
			result[ 0 ] = line.substring( 0, index );
			if( ! this.ignoreComments ) {
				// Find extra spaces before the in-line comment and put them in the comment
				Matcher m = Pattern.compile( "(\\s+)$" ).matcher( result[ 0 ]);
				String prefix = "";
				if( m.find())
					prefix = m.group( 1 );

				result[ 1 ] = prefix + line.substring( index );
			}

			result[ 0 ] = result[ 0 ].trim();
		}

		return result;
	}
545127
public static Map<String,ExportedVariable> parseExportedVariables( String line ) {

		Pattern randomPattern = Pattern.compile( ParsingConstants.PROPERTY_GRAPH_RANDOM_PATTERN, Pattern.CASE_INSENSITIVE );
		Pattern varPattern = Pattern.compile( "([^,=]+)(\\s*=\\s*(\"([^\",]+)\"|([^,]+)))?" );

		Map<String,ExportedVariable> result = new LinkedHashMap<> ();
		Matcher varMatcher = varPattern.matcher( line );
		while( varMatcher.find()) {

			String key = varMatcher.group( 1 ).trim();
			if( Utils.isEmptyOrWhitespaces( key ))
				continue;

			String value = null;
			if( varMatcher.group( 3 ) != null ) {

				// We do not always trim!
				// Surrounding white spaces are kept when defined between quotes.
				if( varMatcher.group( 5 ) != null )
					value = varMatcher.group( 5 ).trim();
				else
					value = varMatcher.group( 4 );
			}

			ExportedVariable var = new ExportedVariable();
			Matcher m = randomPattern.matcher( key );
			if( m.matches()) {
				var.setRandom( true );
				var.setRawKind( m.group( 1 ));
				key = m.group( 2 ).trim();
			}

			var.setName( key.trim());
			if( value != null )
				var.setValue( value );

			result.put( var.getName(), var );
		}

		return result;
	}
1004379
private String mkPreview(int line) {
        StringBuilder sb = new StringBuilder();
        int startLine = line - 3;
        int endLine = line + 3;
        List<String> lines = multiSourceReader.getData();
        for (int i = 0; i < lines.size(); i++) {
            if (i >= startLine && i <= endLine) {
                sb.append(lines.get(i)).append('\n');
            }
        }
        return sb.toString();
    }
1145553
private String readCommand(String line) throws CDKException {
        if (line.startsWith("M  V30 ")) {
            String command = line.substring(7);
            if (command.endsWith("-")) {
                command = command.substring(0, command.length() - 1);
                command += readCommand(readLine());
            }
            return command;
        } else {
            throw new CDKException("Could not read MDL file: unexpected line: " + line);
        }
    }