hi,
i need help to research about search pattern,as u know we can use some search pattern for searchoin in our codes like.jpg"|".txt"|".asp"|".css"|"*.cs", I wanna know more about, how many search pattern exist? ...

Recommended Answers

All 12 Replies

Hi Firozeh, welcome here at DaniWeb.
I guess you need to know more about regular expressions, called Regex

Hi Firozeh,

Adding to what ddanbe just said:
If you're searching for files in some directory, you can use the following:

System.IO.Directory.GetFiles("dire_path", "*.cs")

EDIT:
You can use two search patterns in the previous command:
*: Zero or more characters.
?: Exactly zero or one character.

More in the following link.

THX dear ddanbe & The Diamonds, but I think it's about filtering in programing specially in C#. i need differnt kind of search pattern ,as The Diamonds said. can u tell me more about?

Do you mean file extensions?

Based on your question "How many search patterns exist" this is quite vague. seeing as there are just as many search patterns as there are file extensions.

When using something like an openFileDialog you specify the extensions you want to import based on your own personal preference.

u know, i'm researching about and its concept is vague for me too. as i know in our programming, for example in C#, we use some search pattern that help us to find things, look this sample code,
`

 string pattern = "*.gif|*.jpg";`
`    FileInfo[] files = dir.GetFiles(pattern);`

as u(dear Fenrir()) said there are many search pattern, how we use them? or it's better ask, are there any spetial role to use them? or not just we use file extention that we want and use them with some spetial characters(like *,.,#,...)? and are thay use just for files? for example can we use some search patterns for searching name or some thing else(except using regular expression)?

So you're asking about files-names search patterns..

First there is the asterisk (*), it matches zero or more characters as follows:

  • (*.cs) matches all .cs files (e.g. myclass.cs, yourclass.cs)
  • (m*.cs) matches all .cs files that starts with letter m (e.g. moonclass.cs)

and so on...

Second there is the quistion mark (?), it matches zero or one character as follows:
- (???.cs) matches file names that have at most three characters before file extension (e.g. kbs.cs, mr.cs, p.cs)
- (s??p.cs) matches file names that start with letter s and ends with letter p and contains no more than four characters before file extension (e.g soup.cs, soap.cs, sp.cs)

THX friends!i saw .(as The Diamonds said, it's meaning should be all files whit any extensions) some where, there is any resources that give me more example of this kind of search pattern?

You can match any file with any extension by:

*.*

If you want another pattern just give me the specification then I can help you.. I couldn't find any link that provide examples more than what I've already provided.

To be honest, this is not kind of big topic to cover.. you only need to understand the use of astrisk (*) & question mark(?) and everything would follow by its own. Write any combination and test it yourself, it is pretty much easy.

no, i undrestand your meaning about * and ?.it was clear(thanks The Diamonds) as u said, it's easy, no problem. i thought may we can use another characters for search too, except * and ?.thank you for your help. have fune!

As far as I know it is just * and ? that can be used.

You're welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.