JAJAH Development Blog
IMA’s Mobile Advertising event
July 3rd, 2008For women Only; a none testosterone event in the hitech world
June 28th, 2008Count words Using Regular Expression
June 28th, 2008I used regular expression to filter the strings. For this purpose I created two functions:
RemoveExtraSpaces - Remove extra spaces from string. The function allow only one space between each word.
CountWords - The function return number of words in a string. It use the function RemoveExtraSpaces and use regular expression to remove HTML Code , New Lines and Dividers.
/// <summary>
/// This function remove Extra spaces , the Regular expression is
looking for white spaces that appears 2 times and more
/// </summary>
/// <param name="s">This is the string that we want to check</param>
/// <returns>Fixed String</returns>
private string RemoveExtraSpaces(string s)
{
Regex FindExtraSpace = new Regex("\\s{2,}");
return FindExtraSpace.Replace(s, " ");
}
/// <summary>
/// This function return the number of words in a string that are
/// separated by space
/// </summary>
/// <param name="strText">The text that we want to check</param>
/// <returns>number of words</returns>
public int CountWords(string strText)
{
string exp = "#;#";
// The expression look for Html and new lines and the divider that
// we define before
Regex Match = new Regex("<[^>]+>|" + exp + "|\r\n|\n");
// Replace the tags with an empty string so they are not
// considered in count
strText = Match.Replace(strText, "");
// Remove the extra Spaces
strText = RemoveExtraSpaces(strText);
// Count the words in the string by splitting them wherever a
// space is found
return strText.Split(' ').Length;
}
Regular Expression in C#
June 25th, 2008
Private void regExample()
{ string str = “Hello. My name is Inigo Montoya. You killed my father prepare to die.”;
string exp = @”\binigo\b”;
Regex ex1 = new Regex(exp,RegexOptions.IgnoreCase);
// /b in the end and in the begining means that the word is Inigo and not part as other words like Inigojbkbj
// Moreover the option IgnoreCase mean that there is no meaning to the letters case.
Console.WriteLine(ex1.IsMatch(str));
// Match can give you more data where this string is located
Match match = ex1.Match(str);
Console.WriteLine(“Found string ‘” + match.Captures[0].Value + “‘ in:” + match.Captures[0].Index);
Console.WriteLine(ex1.Replace(str, “David”));
// Let’s find Inigo and afterward somewhere in the string should appear the word father
Regex ex2 = new Regex(@”\bInigo\b.*\bfather\b”);
match = ex2.Match(str);
foreach (Capture c in match.Captures)
{
Console.WriteLine(“Found the pattern in:” + c.Value + ” in Index: “ + c.Index);
}
}
Special Characters that can help us search a pattern:
|
Character
|
Description
|
Example
|
|
/b
|
Matches at the position between a word character
|
/blior/b mean that the search will look for the word lior
|
|
| |
Causes the regex engine to match either the part on the left side, or the part on the right side
|
Abc | def – check for abc or def
|
|
. |
Match any single character
|
Ab. à can be ab or abc , and and so on..
|
|
^ |
Matches at the start of the string
|
^ab – the string need to start with ab
|
|
[^]
|
Accept any character expect the characters in bracket
|
[^d-f] – expect all charcters d or e or f
|
|
$
|
Verify the end of the string
|
Def$ - check if the string end with def
|
|
* |
Repeats the previous item zero or more times
|
a* - a,aa,aaa,aaaa,aaaaaaa
|
|
+
|
Repeat the previous item one or more times |
a+ - aa,aaaa,aaaaaa
|
|
?
|
Zero or one of the preceding item
|
Dogs? -> dog, dogs
|
|
{n}
|
{n} where n is an integer >= 1
|
B{2} = bb
|
|
{n,m}
|
{n,m} where n >= 0 and m >= n
|
B{2,4} = bb,bbb,bbbb
|
|
{n,} |
Repeat the previous item at least n times
|
D{2} = dd, dddd and so on.
|
|
/d
|
Any number
|
0-9
|
|
/w
|
Any number or letter
|
1,2,3,a,b,d,g and so on.
|
|
/s
|
Match any whitespace character
|
|
For Women Only; F5 - Refreshing women venture’s First meeting
June 21st, 2008MVC, Design Patterns and Real-Life
June 20th, 2008Facebook: how to create a gift application for facebook in 3 minutes
June 14th, 2008
For some time, I wanted to create some application for Facebook. I usually dont like must of the facebook applications, but I encountered a really cool gift application called Gothic Gifts.
In order to reveal new gifts, you need to send friends gifts, and since I was very intrigued to see the available gifts… I find myself using that application allot…
In the top of the application I noticed an option to create your own gift. clicking on the link, I got a wizard application called Gift Creator. This is a wizard for creating an application without needing to have the knowledge of a developer, or in my case PHP. (although I know many things, I didn’t get the chance of working with PHP…yet…)
So to make things short, what you need to do is this:
1- Install the make gift application
2- Follow the instructions
3- That’s it!
The instructions are very simple and well explained. I whish all program installations would be clear as the instructions in this wizard (including the .Net Web Services Wizard…).
In the process of creating your gift application you first uploads the images - a.k.a the gifts, then you install the Facebook Developer and you are left with 3 simple and clear stages, that the Gift Creator guides you through:.
1- Create a new application in Facebook
2- Update the Gift maker application with the Facebook Keys
3- Update the resulting application URL in the Facebook application
Have Fun!, and no, Im not telling what is my gift application
10 Things You Probably Didn’t Know About Cell Phones
June 14th, 2008
Cell phones are amazing, in the way it changed our lives completely, and how it rapidly transformed from a symbol of status owned only by a handful of people to a device owned by almost half of the world population with over 3.3 active cell phone as of today.
“Over 30% of South Korean students send 100 text messages a day”.
"The First Cell Phone Came Out in 1983"
"Just under two-thirds of cell phone users use the backlight as a flashlight"
These and some other fun facts about cell phones can be found here
IPhone II – The device that users really waited for
June 9th, 2008Apple just releases the new IPhone. The first IPhone released in June 2007 and become a big success. The combination between a portal media player and a phone cause a lot of people to buy it.
|
The new IPhone has some new great features like: - 3G-capable. 2.8 times faster than EDGE. |
Today users are looking for one device that has it all: Music, Video, GPS and a phone. Users don’t want to carry several devices for these features and they want one device that delivers these features in good quality. The new IPhone give this answer and this is why there are so many people from all over the world waited for IPhone II.
It’s seems like Apple hears what users really want and make sure it’s implemented for example: 3G, GPS, support in Microsoft Exchange (Will be available in Firmware 2.0) and ect.
In my opinion the success of the IPhone II is assured and in the following year the IPhone market is going to increase dramatically.
