All algorithms below are optimal alphabet-independent parallel CRCW PRAM algorithms. In one dimension: Given a pattern string of length m for the string-matching problem, we design an algorithm that computes a deterministic sample of a sufficiently long substring in constant time. This problem used to be a bottleneck in the pattern preprocessing for one- and two-dimensional pattern matching. The best previous time bound was O(log2 m/log log m). We use this algorithm to obtain the following results. 1. Improving the preprocessing of the constant-time text search algorithm from O(log2 m/log log m) to O(log log m), which is now best possible. 2. A constant-time deterministic string-matching algorithm in the case that the text length n satisfies n = Ω(m1+ε) for a constant ε>0. 3. A simple probabilistic string-matching algorithm that has constant time with high probability for random input. 4. A constant expected time Las-Vegas algorithm for computing the period of the pattern and all witnesses and thus string matching itself, solving the main open problem remaining in string matching. In two dimensions: Given an m×m pattern, we present the first optimal alphabet-independent parallel algorithm for two-dimensional pattern matching which requires constant-time text processing following O(log log m)-time preprocessing of the pattern. This algorithm depends upon three new time- and work-optimal results, one of which is the constant-time deterministic sample computation above. The second is a simple constant-time two-dimensional pattern matching algorithm, given a deterministic sample and two-dimensional witnesses. The best previous optimal two-dimensional text search takes O(log log m) time. The third is an O(log log m)-time algorithm that computes two-dimensional witnesses. No optimal parallel algorithm was known before. The best previous algorithm takes O(log m) time and uses O(m2 log m) operations and more than linear space.