0
Okay I'm newbie here... what's the difference between regex and searching algorithms I mean when we use regex and when the othe?
2 odpowiedzi
+ 2
Regular expressions are expressions. It's a set of symbols used in a way which can represent the general pattern/form of a string. Regex on itself has little to do with searching for a substring in a string, and is mainly used to describe what a string looks like.
Searching algorithms are algorithms used to find a particular object among many other objects. String searching algorithms, in particular, are used to find the location of a specific sequence of characters within a given string. E.g. https://en.m.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm
In programming, regex is commonly used together with string searching algorithms so that programmers can easily identify if a general pattern exists within a string, or if a string conforms to the defined pattern.
+ 2
A regular expression is not a searching algorithm. It just defines a search pattern, which a searching algorithm can use.