text: Q:
  
  Start of String Java regex
  
  I want to match an occurrence of 1 that comes after either the beginning of the String or a.
  I've tried [\Aa]1, but this gives me a PatternSyntaxException.
  
  A:
  
  Try a pattern like this:
  (^|a)1
  
  The ^ will match the begining of the string, while the a will match a literal Latin letter a. The | is called an alternation, and will match either the pattern on the left or the right, while parentheses restrict the scope of the alternation.
  Now, this will include the a as part of the matched string. If you'd like to avoid this you can either use a lookbehind, like this:
  (?<=^|a)1
  
  This will match a 1, but only if it is immediately preceeded by the beginning of the string or a Latin letter a.
  
  