CIS-SM practice question 20 of 25
Which one of the following Regular Expressions could be used to parse "San Diego" from the string "Location San Diego"?
Full set: 106 questionsThe regular expression Location (\w+ \w+) is designed to find the literal string "Location " followed by a pattern that captures a two-word phrase. The \w+ component matches one or more "word" characters (alphanumeric characters plus underscore), which correctly identifies "San" and "Diego" individually. The space between the two \w+ tokens matches the literal space. The parentheses () around the pattern \w+ \w+ create a capturing group, which isolates and extracts "San Diego" from the full string.
A. Location (\W) (\w): This expression captures a single non-word character (the space) followed by a single word character ("S"), not the intended "San Diego".
B. Location (L): This expression looks for zero or more occurrences of the literal character 'L' after "Location ", which does not match the space in "Location San Diego".
D. Location (W): This expression looks for the literal uppercase character 'W' after "Location ", which is not present in the source string. ---
1. ServiceNow Developer Documentation, "Regular expression support in scripts": This official guide details the regular expression syntax used in ServiceNow server-side scripts, which is based on Java's regex engine. It defines \w as a predefined character class for a word character [a-zA-Z0-9] and + as a greedy quantifier for one or more matches. This directly supports the use of \w+ to match "San" and "Diego". (ServiceNow Developer Site -> API Reference -> Scripting in ServiceNow -> Server-side script basics -> Regular expression support in scripts).
2. ServiceNow Product Documentation, "Create a parsing rule": In features like Log Analytics, parsing rules are used to extract data from log lines using regular expressions. The documentation provides examples of using capturing groups () with quantifiers like + to extract variable-length strings, which is the principle applied in the question. (ServiceNow Product Documentation, Vancouver -> IT Operations Management -> Log Analytics -> Create a parsing rule, Section 2.d).
3. Stanford University, CS103 Courseware, "Guide to Regular Expressions": University courseware on automata theory provides foundational knowledge of regular expressions. These guides define the core components used in the question, explaining that \w is a shorthand for a class of characters and + is a quantifier for "one or more repetitions," validating the construction of the correct answer from first principles. (Reference: Stanford CS103: Mathematical Foundations of Computing, Handout #19, "Guide to Regular Expressions," pp. 1-2).
Keep practicing
Take the free CIS-SM practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CIS-SM practice questions
- Question 2Which of the following are methods used to initiate discovery on a service? (Choose three…
- Question 3In Event Management, which of the following rules allows for automatic task creation?
- Question 4Which one of the following best describes the process that Service Mapping uses to run a …
- Question 5In Service Mapping, when discovery is started, what is the execution strategy used to run…
- Question 6In ServiceNow Discovery, which one of the following phases is the server RAM value discov…
- Question 7Predictive Intelligence provides which one of the following benefits?
