mardi 26 mai 2015

Regex Pattern to match only first sign of a String

I want the pattern to match the exactly first sign of a String. The sign can be everything: whitespace, character, digit... but it should be only the first.

^.{1} was my guess, but ends in infite loop on string "123 void"

public CatchAll(String string) {
                pattern = Pattern.compile("^.");

Language is Java, ^. loops infitite.

Suggestions for such a pattern?

Aucun commentaire:

Enregistrer un commentaire