Solved

explain . and * in context of searching

Posted on 2004-08-14
11
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 11

Expert Comment

by:avizit
ID: 11801329
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
ID: 11801831
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
ID: 11802290
I guessed that it might be vi style coshe says "search" and gives /..i*  i.e one slash
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 1

Author Comment

by:decentswati
ID: 11806937
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
ID: 11807054
explain the difference in behaviours  
0
 
LVL 1

Author Comment

by:decentswati
ID: 11817263
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
ID: 11866120

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
ID: 11866354

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
ID: 11877628
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
ID: 11983365
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
ID: 12040338
Some Good Information for reference:
http://www.regular-expressions.info/
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 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