Solved

explain . and * in context of searching

Posted on 2004-08-14
11
194 Views
Last Modified: 2010-04-22
Hello Everybody,
explain the behaviour of this 2 symbols.they are behaving strangely.
see the output using
/..i*
/.i*
/i*
/*i*
thanks in advance.
0
Comment
Question by:decentswati
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 11

Expert Comment

by:avizit
Comment Utility
I am not sure in what context you are asking

but I am assuming you are doing searches in  say VI editor

then in that case these are just regular expressions

the '.' means any character , and a * means any number of the previous character

so /..i*  will mean search for  any two charcaters followed by any number of occurences of  the character 'i'

and /i* would be any number of occurences of 'i' ( including zewro occurence)

you can similarly decipher the other regular expresisons using http://sitescooper.org/tao_regexps.html
0
 
LVL 22

Expert Comment

by:pjedmond
Comment Utility
These chars have special meanings in the contect of regular expressions for commands such as grep

http://www.regular-expressions.info/

Perl style regexs:

http://etext.lib.virginia.edu/helpsheets/regex.html

Editors such as vi - an example given above.

Shells (file name wildcards):
http://cds.dl.ac.uk/cds/manuals/unix_guide/node31.html

If none of the above matches what you intended, then please provide the circumstances in which you are using those combinations.
0
 
LVL 11

Expert Comment

by:avizit
Comment Utility
I guessed that it might be vi style coshe says "search" and gives /..i*  i.e one slash
0
 
LVL 1

Author Comment

by:decentswati
Comment Utility
Hi,
I am using this search in Vi.Given expression are showing different behaviour also in normal conditions.please explain
0
 
LVL 11

Expert Comment

by:avizit
Comment Utility
explain the difference in behaviours  
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:decentswati
Comment Utility
hello,
this is my vi file..
Good Morning India.(1st line)
For every beauty there is an somewhere to see it.(2nd line)
Windows 2000 professionals are working in IBM (3rd line without '.')
Good to see.Once an elephant goto city to buy some(4th line) cakes.(5h line)

the behave with different search operations are

..i*  --> it selects all the text except the M of IBM in 3rd line.

i*    --> it selects all the text and increase by one character in each line.

.i*   --> it selects all the text.

I need an explanation why it is so.
Thanks..
0
 
LVL 5

Expert Comment

by:ITcrow
Comment Utility

Please refer regular expression details of vi / vim.
http://www.geocities.com/volontir/#pattern

This will clarify a lot.
0
 
LVL 5

Accepted Solution

by:
ITcrow earned 100 total points
Comment Utility

Swati,

I think, I understand what you are talking about.

Here is what I think is going on:

..i*  --> it selects all the text except the M of IBM in 3rd line.
It is looking for ".." match, since Newline is \r\n, regex pairs up M with newline
character which cannot be shown as selection when looking for .[alphanum]*

i*    --> it selects all the text and increase by one character in each line.
Star selects new line character, in addition to the characters in the line.

.i*   --> it selects all the text.
Inclusion of 'dot' ignores selection of newline characters.

Some more to play:

Try:

...i/  ( dot dot dot any_alpha_num star ) and ( dot dot dot dot i star )

If you could see your special characters then you will see that .. ( dot dot ) is
matching first, so star match doesn't even kick in. But, special char cannot be
selected, it doesn't show either of those characters in selection.

0
 
LVL 1

Author Comment

by:decentswati
Comment Utility
Hi Itcrow,
 I got ur point but I donot understand when to use what,so that I can be handy with these things.If there is another site that explain these things in detail,please tell.thanks...
0
 
LVL 5

Expert Comment

by:ITcrow
Comment Utility
Swati,

You need to familiarize your self with 'regular expressions'. A simple search for 'regex' on google will give you plenty of good read. Knowledge of regex is pretty much consistent amongst languages.

Something to start with: http://www.anaesthetist.com/mnm/perl/regex.htm
0
 
LVL 5

Expert Comment

by:ITcrow
Comment Utility
Some Good Information for reference:
http://www.regular-expressions.info/
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now