Top "Pattern-matching" questions

Use this tag for questions about testing whether a data structure has a particular shape or contains particular values in certain locations.

Count character occurrences in a string in C++

How can I count the number of "_" in a string like "bla_bla_blabla_bla"?

c++ string pattern-matching
How to find a whole word in a String in java

I have a String that I have to parse for different keywords. For example, I have the String: "I will …

java string pattern-matching stringtokenizer
How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?

Say I want to copy the contents of a directory excluding files and folders whose names contain the word 'Music'. …

bash shell pattern-matching glob
How to select lines between two marker patterns which may occur multiple times with awk/sed

Using awk or sed how can I select lines which are occurring between two different marker patterns? There may be …

shell unix sed awk pattern-matching
Check if string ends with certain pattern

If I have a string like: This.is.a.great.place.too.work. or: This/is/a/great/place/too/…

java regex string pattern-matching
Pattern matching using a wildcard

How do I identify a string using a wildcard? I've found glob2rx, but I don't quite understand how to …

r pattern-matching wildcard
Ruby Regexp group matching, assign variables on 1 line

I'm currently trying to rexp a string into multiple variables. Example string: ryan_string = "RyanOnRails: This is a test" I've …

ruby regex pattern-matching
byte[] array pattern search

Anyone know a good and effective way to search/match for a byte pattern in an byte[] array and then …

c# pattern-matching
how to check if given c++ string or char* contains only digits?

Or from the other way around find first non digit character. Do the same functions apply for string and for …

c++ string pattern-matching
Match multiple cases classes in scala

I'm doing matching against some case classes and would like to handle two of the cases in the same way. …

scala pattern-matching