Read File From Path in Vb.net Using Regular Expression

Linux Regular Expression

Introduction to Linux Regular Expression

The Linux regular expression, basically information technology is a sequence of characters or string that would define the searching blueprint. These searching patterns are used by the cord search algorithms like vim, half dozen, sed, awk, notice, grep, etc. It is a very powerful tool in Linux. Nosotros can use the same regular expression to place or search the circuitous values in terms of row and column level. The Linux regular expression is likewise called as regexp or regex.

Syntax of Regular Expression command:

search/read command<design><fileName>

  • search/read control: We can use any searching or reading command in Linux similar vim, vi, sed, awk, observe, grep, etc.
  • pattern: We need to provide the regular expression pattern in the syntax.
  • file proper noun: Input file.

How Linux Regular Expression Command works?

The regular expression is nothing but a symbolic representation in the searching algorithm. In any search algorithm, nosotros need to laissez passer these regular expressions to place the complex string available in the input string or input information.

At that place are lots of different types of regular expression available in the Linux ecosystem.

Sr. No Regular Expression Symbol Description
1 . It volition supplant any grapheme.
2 /b It will match the empty graphic symbol or string at the edge.
three /B Information technology will friction match the empty character or cord at the non-edge.
4 ^ It volition match the cord of the cord.
v \< It will friction match the empty string in the beginning at the word.
half dozen $ It will friction match the character at the stop of the string.
7 \> It will match the empty string at the cease of the word.
8 \ Information technology volition correspond the special characters.
9 () It will grouping the regular expressions.
x ? It volition match the aforementioned or exactly 1 character.

Examples of Linux Regular Expression

Given below are the examples mentioned:

Instance #one

Regular Expression with "^" symbol.

In the Linux regular expression, we are able to search the starting of the string associated with the "^" symbol. To search the string we need to employ any text/string editor or searching algorithm.

Code:

cat file.txt | grep ^t

Explanation :

We are having a sample directory, in the same directory at that place is filename "file.txt". There are records in information technology. We are using the file.txt as an input to Linux regular expression. Nosotros need to identify the records that are starting with character "t".

Output:

Linux Regular Expression 1

Linux Regular Expression 2

Example #2

Regular Expression with "$" symbol.

In the Linux regular expression, nosotros are able to search the ending of character or string associated with the "$" symbol. To search the cord, we need to apply whatever text/string editor or searching algorithm.

Lawmaking:

true cat file.txt | grep e$

Explanation:

In the same directory, in that location is filename "file.txt". There are few records in it. We are using the file.txt as an input to Linux regular expression "$". We need to place the records that are ending with graphic symbol "e".

Output:

Linux Regular Expression 3

Example #3

Linux Regular Expression – Interval.

There are dissimilar types of regular expression in Linux. Interval is one of them. With the help of interval expression, we are able to find the expression that are coming number of occurrences in a string.

Nosotros need to use the "-E" pick with the character/cord interval value.

Code:

cat file.txt | grep -Due east e\{2}

Explanation:

In the Linux ecosystem, nosotros can able to search the dissimilar combination of character. As per the to a higher place command, nosotros are able to discover the same sequence of character number of time as per the given value assign in the command. We are identifying the sequence of character "eastward" coming two times in the string.

Output:

Linux Regular Expression 4

Instance #4

Regular Expression with "\+" symbol.

In the regular expression, we want to filter out the matches i or more than occurrences of the previous character from the input file.

Code:

true cat file.txt | grep "n\+east"

Explanation:

We are using the input file as "file.txt". Nosotros demand to search the string from starting character as "due north" and aide grapheme as "east". As per the to a higher place command, we are searching for a specific combination of characteristics from the input file.

Output:

with

Example #5

Regular Expression with Separating Words.

In the Linux Regular Expression, we are able to find the exact matching string from the input file. We demand to employ the "\b<string proper noun>\b" selection with any text/cord editor or searching algorithm.

Code:

grep '\bfive\b' file.txt

Explanation:

In Linux regular expression, we are able to discover a specific string or character from the input file/data. Every bit per the higher up control, we specific regular expression to find the exact string. We are using "\b\b" option into which we need to keep the search string.

Output:

Separating Words

Example #6

Regular Expression with "*" symbol.

In Linux regular expression, we are able to find or search the zero matches or more times in the preceding grapheme. We need to utilize the "*" pick with whatsoever text/string editor or searching algorithm.

Code:

grep "[AB]p*" file.txt

Explanation:

As per the above command, we are identifying the just "A" & "B" upper cases character and all graphic symbol or string from the lowercase alphabetic character "p". Accordingly, the given input we are able to get the relevant cord from the input file.

Output:

with

Instance #7

Expression with "\?" symbol.

In the regular expression, we desire to filter out the matches zero or more occurrences of the previous graphic symbol from the input file.

Lawmaking:

cat file.txt | grep "north\?e"

Explanation:

Nosotros are using the input file every bit "file.txt". We need to search the string from starting character equally "north" and adjutant grapheme as "e". As per the above control, we are searching a specific combination of characteristics from the input file and it will search all the character come under the input file.

Output:

with

Conclusion

We have seen the uncut concept of "Linux Regular Expression Control" with the proper example, caption and control with different outputs. The regular expression is a very powerful command tool to process any type of data. It is widely used in shell/bash jobs, searching tools, etc.

Recommended Articles

This is a guide to Linux Regular Expression. Hither we talk over the introduction to Linux Regular Expression along with the working of command and the examples for understanding amend. You may as well have a wait at the post-obit articles to learn more than –

  1. Remove dir Linux
  2. Linux Filter Commands
  3. Linux Create File
  4. Linux List Users

logantheive.blogspot.com

Source: https://www.educba.com/linux-regular-expression/

0 Response to "Read File From Path in Vb.net Using Regular Expression"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel