The default Ruby debugger allows you to set breakpoints and watchpoints and evaluate variables while your programs execute.
The default Ruby debugger allows you to set breakpoints and watchpoints and evaluate variables while your programs execute.
The split method splits a string into substrings, based on a pattern. The results (minus the pattern) are returned as an array; an empty pattern splits a string into characters
Matching from the start or end of a string becomes more useful when it forms a part of a more complex pattern. Often such a pattern tries to match zero or more instances of a specified pattern.
Frequently, it is useful to attempt to match some expression from the very start of a string; the character ^ followed by a match term is used to specify this.
You could use these techniques to determine specific characteristics of strings, such as whether or not a given string is uppercase, lowercase or mixed case
While we’ve used forward slash delimiters in the Making Matches, there are alter-native ways of defining regular expressions: you can specifically create a new Regexp object initialized with a string
Just about the simplest regular expression would be a sequence of characters, such as ‘abc’, which you want to find in a string.
The MatchData class supplies the pre_match and post_match methods to return the strings preceding or following a match. Here, for example, we make a match on the comment character
This is a list of some of the elements which can be used in regular expressions...
^ beginning of a line or string
$ end of a line or string
. any character except newline