Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

explain . and * in context of searching

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
decentswati
Asked:
decentswati
  • 4
  • 3
  • 3
  • +1
1 Solution
 
avizitCommented:
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
 
pjedmondCommented:
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
 
avizitCommented:
I guessed that it might be vi style coshe says "search" and gives /..i*  i.e one slash
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
decentswatiAuthor Commented:
Hi,
I am using this search in Vi.Given expression are showing different behaviour also in normal conditions.please explain
0
 
avizitCommented:
explain the difference in behaviours  
0
 
decentswatiAuthor Commented:
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
 
ITcrowCommented:

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

This will clarify a lot.
0
 
ITcrowCommented:

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
 
decentswatiAuthor Commented:
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
 
ITcrowCommented:
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
 
ITcrowCommented:
Some Good Information for reference:
http://www.regular-expressions.info/
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now