Quantcast
Channel: Is there a difference between a (general) pattern and a string pattern? - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Domen for Is there a difference between a (general) pattern and a string pattern?

$
0
0

Yes, there is a difference. "A" ~~ ___ is not a pattern but a StringExpression, which you can see by observing its FullForm:

"A" ~~ ___ // FullFormStringExpression["A", BlankNullSequence[]]

StringExpression is used as an analog of Pattern for strings (more about Working with String Patterns).

Therefore, there are two different functions: MatchQ (with corresponding Position) and StringMatchQ (with corresponding StringPosition). While MatchQ expects a pattern, StringMatchQ expects a StringExpression (or RegularExpression), which is mentioned under the first bullet point in Details and Options.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>