Question

How to search a string using a basic regular expression in Vi editor? How about using...

How to search a string using a basic regular expression in Vi editor? How about using extended regular expression in Vi editor?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Using Basic Regular Expression

If you want to search a string starting with "no" and ending with "on"

Press / to search string one by one

and then regular expression no.*on

where . denotes any character but not end of line(EOL)

and * denotes repetition on previously occured characters

Press enter to mve cursor to the found string

Press n to find next occurence.

OUTPUT:

Using Extended Regular Expression

Use :set to enable use of extended regular expression in vi editor

This can be used as extended regular expression

:%s/v([0-9])/

0-9 is used to find numbers in expression

v is used so that there is no need to write ( or ) and simple ( or ) and be typed

Add a comment
Know the answer?
Add Answer to:
How to search a string using a basic regular expression in Vi editor? How about using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Part II: Regular Expression 1. Chose match(es) for each given basic/extended regular expression (maybe multiple correct...

    Part II: Regular Expression 1. Chose match(es) for each given basic/extended regular expression (maybe multiple correct matches) and describe the pattern of matched string for 3), 4), 5),6), 11) e.g. (ab+a, (extended regex ) a) ababa b) aba c)abba d)aabba e)aa Answer: b,c; Pattern : The matched string should begin and end with 'a and ‘b' occurs at least once between leading and ending ‘a') ote: 1) to 5)are basic regexes 1) 'a[ab]*a' (a)ababa (b) aaba (c) aabab (d) aabbaa...

  • 5. Describe informally the kind of pattern that matches the following extended regular expression: [b-d]a?e+ and...

    5. Describe informally the kind of pattern that matches the following extended regular expression: [b-d]a?e+ and rewrite it using only the basic (not extended) features of formal regular expressions. [For example, character classes [.1 positive closures +, and optionals? are not basic features, and should be expressed using only the basic taxonomy instead]. [4 marks 6. Explain the assertion that " there is more to taking Compiler Construction course than solely at writing a typical compiler" aiming [3 marks 5....

  • 5. Describe informally the kind of pattern that matches the following extended regular expression: [b-d]a?e+ and...

    5. Describe informally the kind of pattern that matches the following extended regular expression: [b-d]a?e+ and rewrite it using only the basic (not extended) features of formal regular expressions. [For example, character classes [.1 positive closures +, and optionals? are not basic features, and should be expressed using only the basic taxonomy instead]. [4 marks 6. Explain the assertion that " there is more to taking Compiler Construction course than solely at writing a typical compiler" aiming [3 marks

  • Hi, What is in your opinion in this message related to Vi Text Editor? I have...

    Hi, What is in your opinion in this message related to Vi Text Editor? I have never used a vi text editor before. I have always used word processors like Microsoft Word or notepad. It was very interesting to learn the basics of a text editor and learn that you can make a file right from that by using a couple of commands. I believe I would be able to use the text editor in the work field but I...

  • I. Write a regular expression that matches a string of bits only if: it starts with...

    I. Write a regular expression that matches a string of bits only if: it starts with a '0', ends with a '00', and has a '1' between every '010'.

  • Regular Expression processor in Java Overview: Create a Java program that will accept a regular expression...

    Regular Expression processor in Java Overview: Create a Java program that will accept a regular expression and a filename for a text file. The program will process the file, looking at every line to find matches for the regular expression and display them. Regular Expression Format The following operators are required to be accepted: + - one or more of the following character (no groups) * - zero or more of the following character (no groups) [] – no negation,...

  • Write a PHP regular expression pattern that matches a string that satisfies the following description: The...

    Write a PHP regular expression pattern that matches a string that satisfies the following description: The string must begin with the (uppercase) letter A. Any three alphanumeric characters must follow. After these, the letter B (uppercase or lowercase) must be repeated one or more times, and the string must end with two digits.

  • 4. A regular expression for the language over the alphabet fa, b) with each string having...

    4. A regular expression for the language over the alphabet fa, b) with each string having an even number of a's is (b*ab*ab*)*b*. Use this result to find regular expressions for the following languages a language over the same alphabet but with each string having odd number of a's. (3 points) a. b. a language over the same alphabet but with each string having 4n (n >- 0) a's. (3 points)

  • Write a regular expression that captures the set of strings composed of 'a', 'b', and 'c',...

    Write a regular expression that captures the set of strings composed of 'a', 'b', and 'c', where any string uses at most two of the three letters (for example, "abbab" is a valid string, or "bccbb", or "ccacaa", but not "abccba": strings that contain only one of the three letters are also fine). Give a non-deterministic finite automaton that captures the regular expression from Using the construction described in class, give a deterministic version of the automaton. Repeat the previous...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT