Starter’s Guide to Regular Expression (Regex)

beginners-guide-to-regular-expression-regex

A regular expression is a range of characters forming a pattern that can be searched in a string which is usually used for validation, for example, for validating credit card numbers or for replacing matched text with another string. Moreover, it also has great multiple language support-learn it once and you can use it across many programming languages.

The advantages that REGEX offers may put this function in limelight, but not many developers are interested in using REGEX, in fact, not few people who take a first look at regex, and ignore it completely. Therefore, few developers and web developers can surmount the complexity of REGEX. However, if one can manage to use it, it will produce you with better and faster searching results.

If you get used to JavaScript, you still need to learn all the characters, classes, quantifiers, modifiers, and methods used in regex.

Let’s see a simple example with an explanation. This is a regex.

B[a-zA-Z\d]+

The above regex will look like this in a line, a character ‘B’ followed by at least one of any character between (and including) ‘a’ to ‘z’, ‘A’, to ‘Z’ and numbers 0 to 9.

Here’s a sample of matches in a line highlighted:

Basket, bulb, B12 vitamin, BaS04, N BC company

The above regex will stop the search at

Basket

And return a positive response. That’s because the global modifier ‘g’ has to be specified if you want the regex to look into all the possible matches.

Below are several ways on how to use this expression in JavaScript. The method goes: if found a match return true, else false.

1

2

3

4

5

var input = “your test string”, regex = /B[a-zA-Z\d]+/;

if(!regex.test(input))

alert(‘No match is found’);

else

alert(‘A match is found’);

Let’s try another method: match returns the matches found in an array.

input = “your test string”,

    regex = /B[a-zA-Z\d]+/g,

    /*I’ve added the global modifier ‘g’ to the regex to get all the matches*/

    ary = input.match(regex);   

if(ary===null)

    alert(‘No match is found’);

else

    alert(‘matches are: ‘ + ary.toString());

How about string replace? Let’s try that with regex now.

1

2

3

var input = “your test string”,

regex = /B[a-zA-Z\d]+/g;

alert(input.replace(regex, “#”));

5 PHP Techniques that will Make Web Developer’s Works More Efficient

PHP Tips Every Web Developer Should Know

Like any programming languages, PHP is one of programming languages that need to be understood through its basic details before you get familiar with deeper code. Those basic details include variable declaration, data type, operators, statements controlling the flow of the code and others. If you want to do a better web development, you need to disclosure these 5 tips.

  1. Use Comment to Help You Work As a Team

Like the old saying, two heads are bigger than one, therefore using comment can be a good tip to communicate with your team whenever it comes to do coding. It makes you a good team player when it comes to updating, debugging, analysis, and other post-programming activities which are really easy and efficient since you make the other team players understand your idea of the code.

  1. The Smaller, the better

If you think that creating a long code will make you a great developer, well I am afraid you might get it wrong since it is not about how long your code is but it is all about the output. Therefore, bear in mind for not repeating code and use programming tools, such as functions, objects and array to good effect.

  1. Use isset() instead of strlen()

When dealing with string array, isset() is a better option than strlen() since isset() is more cost efficient in terms of time of the two entities.

  1. Forget $_REQUEST

Forget your old days with $_REQUEST since it is terribly amateur and unsafe to get values for variable. Besides, your POST and GET variables will be opened up and the security concern will be such a big issue once public can access your POST variables.

1

2

$action = $_GET(‘action’);

$name = $_POST(‘name’);

  1. Object Oriented Programming (OOP) is the way forward

If you want to create a data that is more structured in your code, OOP is the best suggestion when it is compared to traditional procedural approach. In a deeper definition, OOP is a language program which orientate to objects. Each data and function in this paradigm is bundled up in classes or objects. It is different from structure programming logic, each object will receive messages, process data, and send message to other objects.

3 reasons why HTML and CSS still relevant for designers in 2016

5 reason why HTML and CSS still relevant for designer in 2016

As a web designer, having HTML and CSS knowledge will sufficient enough to provide you with the best weapon in design world. Not only because these tools are truly gaining lots of popularity, but also because these tools will give you all it takes to be a professional designer in 2016. Here are why:

  1. HTML and CSS are Design Tools

As a matter of fact, HTML and CSS is not suitable to be used for programming matters since they aren’t really programming languages, therefore they don’t compile when there’s an error in your HTML or CSS. Moreover, your browser will automatically skip it or it will show what it thinks you meant and they don’t provide any function statements as they are best at styling and structuring content.

Besides, you will notice that HTML5 and CSS3 are great improvements over previous versions, especially for HTML5 specification which provides meaningful structure to web content; eliminating the need for ugly <DIV> tags everywhere.

  1. CSS3 Is Replacing JavaScript as the Language of Animation on the Web

Even though, HTML5 and CSS3 are programmed for design and not for programming, but some of the new stuff is starting to get kind of programming language. In fact, CSS animation is a great place to start which you can use it to level up your skills, although you don’t know a whole new language.

Moreover, CSS has become the first choice for the language of animation on the web since the death of flash and the power of CSS3 animation properties. In addition, animation and motion design are one of the things for designers to be working on right now.

  1. Wireframes with CSS are better than a Photoshop Mockup

If you have to face a condition where design details in the mockups need to be interpreted into code, CSS can be one of the solutions that bridge the communication between designers and developers. This has proven that CSS has a lot of success in explaining rough design to developers in understanding designer’s prototype.