15 PHP regular expressions for web developers

Tagged:  

Regular Expressions can be very useful tools for web developers. However, they can be a bit tricky to use, especially when you are not very experienced in web or software development. Well, over at Cats who Code they have put together a list of 15 useful regular expressions for web developers. The code is written in PHP, but should be fairly easy to translate to other languages.

Below is an excerpt from the post.

For many beginners, regular expressions seems to be hard to learn and use. In fact, they're far less hard than you may think. Before we dive deep inside regexp with useful and reusable codes, let's quickly see the basics:

Regular expressions syntax

Regular Expression Will match...
foo The string "foo"
^foo "foo" at the start of a string
foo$ "foo" at the end of a string
^foo$ "foo" when it is alone on a string
[abc] a, b, or c
[a-z] Any lowercase letter
[^A-Z] Any character that is not a uppercase letter
(gif|jpg) Matches either "gif" or "jpeg"
[a-z]+ One or more lowercase letters
[0-9.-] ?ny number, dot, or minus sign
^[a-zA-Z0-9_]{1,}$ Any word of at least one letter, number or _
([wx])([yz]) wy, wz, xy, or xz
[^A-Za-z0-9] Any symbol (not a number or a letter)
([A-Z]{3}|[0-9]{4}) Matches three letters or four numbers

 

PHP regular expression functions

Function Description
preg_match() The preg_match() function searches string for pattern, returning true if pattern exists, and false otherwise.
preg_match_all()

The preg_match_all() function matches all occurrences of pattern in string.
preg_replace() The preg_replace() function operates just like ereg_replace(), except that regular expressions can be used in the pattern and replacement input parameters.
preg_split() The preg_split() function operates exactly like split(), except that regular expressions are accepted as input parameters for pattern.
preg_grep() The preg_grep() function searches all elements of input_array, returning all elements matching the regexp pattern.
preg_ quote()

Quote regular expression characters

You can read the full post here.

Google Helps Make the Web Faster

Tagged:  

Google is looking to help developers make the web faster. They have put together quite a few articles on optimizing your web site or web application.

The topics of these articles include:

  • HTTP caching
  • PHP performance tips
  • Optimizing web graphics
  • Optimizing JavaScript code
  • And many more

You can get to all of these articles here.

It's always good when a company like Google helps the developer community with tricks a techniques that they use. So, take a look at a few of these articles and work on making web a faster place.

Visual WebGui released 6.3.7 Platform for Rich AJAX applications

Gizmox released today a new version of the Visual WebGui Platform for Rich .NET AJAX applications.

Visual WebGui 6.3.7 is a further stabilization to the 6.3 pre-release version which adds support for wrapping of AJAX based controls into the Visual WebGui framework as well as support for additional languages.

The platform is available in free open source and free trial (commercial Professional Studio) versions.
All downloads are available for free here!

This is the Change log for 6.3.7:

Breaking Changes
----------------------------------------------------------------------------------------------
VWG-4746- Support for wrapping AJAX based controls added.

Bugs fix
----------------------------------------------------------------------------------------------
VWG-3930 - No control causes the designer window to open dirty - with a star marking changes.
VWG-4763 - VB form designer allows to edit ContextMenu items
VWG-4256 - Button with 21x21 image used tocrop image in a button with size of 25x25.
VWG-4204 - ListView RTL view fixed.
VWG-2599 - When browser is in offline mode a message is shown when the connection to the server is lost.
VWG-2976 - Focus indication on Checked list box focus.
VWG-4751 - Problem deleting SplitContainer contro from designer fixed.
VWG-4355 - Opening a TableLayoutPanel in designer used to automatically add rows.
VWG-4753 - Splitcontainer did not preserve splitter panels order.
VWG-4359 - When setting the CheckBoxes property to TRUE, the selection text used to disappear.
VWG-4309 - Casting safetly tests added in the resource browser dialog classes.
VWG-4344 - Support added for Iceland-Icelandic.
VWG-4403 - Support added for Brazil-Portuguese .
VWG-4311 - Support added for Portugal-Portuguese.
VWG-3792 - UniqueIdExtender renders CUID attribute at run-time - and it's now available in generated HTML code.
VWG-4211 - FCKEditor fixed .
VWG-4243 - TableLayOutPanel render problems fixed fixed.
VWG-4120 - TabControl should re-render on KeepConnceted requests fixed.
VWG-4752 - SplitterDistance property is now saved for the SplitContainer control.
VWG-4390 - TableLayoutPanel fixed to not corrupt layout when saving and reloading
VWG-4662 - Form.DockPadding fixed and wont make controls move on open+save form.
VWG-4483 - Buttons with Flat style text retain's it's location on mouse hover.
VWG-4260 - DateTimePicker with custom format will not change day part to undefined on second tabbing through the DTP control.
VWG-4246 - DataGridViewCell - allows placing typing cursor using mouse to edit contents
VWG-4371 - Tabbing through controls on a form tabstop on buttons with FlatStyle=Flat.
VWG-4244 - IE8 - Dialogs & MessageBoxes showing content.
VWG-4172 - IE8 - Rendering of labels fixed to look the same as in IE7 and FF3.
VWG-4340 - IE8 - Combobox rendering fixed.

Go to Downloads page...

Google Guice 2.0 Released

Tagged:  

Java dependency injection just got better: Google Guice 2.0 has been released.

What's new:

  • Provider methods. You can now annotate methods in your Module so you avoid manually constructing dependencies.
  • Binding overrides. One Module can now override the bindings in another.
  • Private modules. You can now create bindings that are not externally visible, in order to encapsulate your dependency injections.
  • The ability to inject members of sets and maps using Multibinder and MapBinder respectively.
  • ServletModule now provides programmatic configuration of servlets and filters. GuiceServletContextListener can be used to help bootstrap a Guice application in a servlet container.
  • Custom injections. Guice now includes hooks that allow other frameworks to define custom injection annotations. This enables Guice to host other frameworks that have their own injection semantics or annotations.
  • A tree-like structure for Injectors, i.e., an Injector can have children that inherit all of its bindings.
  • An introspection API: like reflection but for Guice bindings.
  • Pluggable type converters that convert constant string bindings to other types, i.e., Dates, URLs, etc.
  • OSGi compatible. Guice now works well in OSGi managed environments, because AOP-generated classes use a bridge classloader.
  • AOP is now optional, so Guice will work on platforms that don't support bytecode generation (Android).

You can download the new release here. The new manual is here. Now all they have to do is update the public Maven repository.

javax.inject.Inject

On related news (Crazy) Bob Lee, the creator of Guice, and Rod Johnson, the creator of Spring, have gotten together to propose a standard set of annotations and interfaces for using dependency injection in Java under the banner of JSR-330: Dependency Injection for Java (still only a proposal, so JSR-330 is a tentative moniker). There is also a corresponding project over at Google Code. The standardization should greatly help the use of dependency injection in shared 3rd party libraries, allowing the application developer to avoid having to initialize more than one dependency injection framework.

These annotations are modelled closely on those currently in Google Guice:

  • @Inject - Identifies injectable constructors, methods, and fields
  • @Qualifier - Identifies qualifier annotations
  • @Scope - Identifies scope annotations
  • @Named - String-based qualifier
  • @Singleton - Identifies a type that the injector only instantiates once

The utility interface Provider is also in the proposed specification.

Chrome Becomes Extensible

Tagged:  

Plugins and extensions for Google Chrome have arrived. As of developer build 2.0.180.0 of Chrome, the browser is now extensible. A page showing how to create extensions recently went up on the Chromium project documentation site as well as some samples--including a Gmail checker. A recent developer release is required to try out the functionality.

The main document page for Chrome extensions is here. Support for extensions is still very early stage, so they are not yet ready for general consumption.

Free Programming Books

Tagged:  

E-Books has compiled a sizeable list of programming books that are available free for download or online viewing. Topics include Ada, Assembly, C/C++, C#, Haskell, Java, JavaScript, LISP, Perl, Python, Ruby, Visual Basic, and XML.

You can view the list here. My favorites? The Structure and Interpretation of Computer Programs, Thinking in Java, Programming Ruby, and Communicating Sequential Processes. But I haven't read all of them--yet :).

Best free HTML editors

Tagged:  

One thing that all web designers need is a good HTML editor. Plus with the economy the way it is the right price is FREE. Well, over at DevelopersVoice they have put together a good list of the best free HTML editors.

Below is an excerpt from the post.

Aptana Studio :

Aptana Studio is the free, open source Web development environment optimized for use with Ajax libraries and scripting languages like JavaScript, Ruby and PHP. Aptana Studio is considered by many developers the best-in-class authoring environment for today’s more rich and interactive Web pages and Ajax applications.

There is also support for Adobe AIR, Apple iPhone, PHP, and Ruby on Rails development, which comes via additional development plugins.

Pros: Complete IDE, many plugins

Cons : Complicated, developer oriented

Homepage : http://www.aptana.com/studio/

Download : http://www.aptana.com/studio/download

Size : 131 MB License Type : Unrestricted Freeware OS : Windows, Mac, Linux
Free HTML editor


KompoZer :

Kompozer is an open source web development tool built on NVU. The project strives to fix bugs in the NVU project and added new features to it. Both the HTML editor as well as the CSS editor has so far be fixed and updated as part of the Kompozer project - and many more changes are scheduled. Apart from that the main feature set is exactly as in NVU. And one of the most important features is still that editing take place in WYSIWYG (What You See Is What You Get) mode allowing you full control of layout as you work with your web design.

Pros: full featured WYSIWYG editor

Cons : not updated , Last release 2006

Homepage : http://kompozer.net/

Download : http://kompozer.net/download.php

Size : 7.6 MB License Type : Unrestricted Freeware OS : Windows 98 – Vista
Free HTML editor

You can read the full post here.

Clojure 1.0 Released

Tagged:  

The first "stable" release of Clojure has been announced. Clojure, a dialect of Lisp built for the JVM, is one of the few languages with built-in Software Transactional Memory (which I describe in more detail here).

There is also a TODO list of desired features targeted for the 1.1 release.

You can download the 1.0.0 release here.

WorkHorse Arrives

Tagged:  

After living on my hard drive for a few months, I finally decided to give my new project a home: http://code.google.com/p/workhorse/ (I literally checked in the initial code today). It's very alpha right now, but the general ideas are starting to take shape.

What is WorkHorse?

WorkHorse is a BPM engine written in Java. It is meant to be both lightweight (i.e., embeddable) and powerful. By the time that I am done, I hope to prove that you don't need to force-fit BPM into BPEL, or even have a heavy-weight XML process description layer at all.

The idea for the project originated with some of the concepts/ideas in BPMN, which I like, though I recognize its weaknesses. Workflow (I am using the older, less trendy term) is a natural fit for so many types of applications, but it often seems that developers avoid it because existing solutions are too cumbersome: they force you to run them on some proprietary server, or they are simply a headache to configure and embed in your existing application.

Can WorkHorse alleviate this headache? Stay tuned.

Oracle Buys Sun

Tagged:  

Oracle announced today that it will buy Sun Microsystems for $7.4 billion, finally ending Sun's search for a suitor. Oracle, a heavy investor in Java technology even prior to its purchase of BEA Systems, was a natural choice after Sun's courtship with IBM failed. As the resident "Java guy" around here, I'd be remiss if I did not share some of my own perspective on the big news.

First, the things I see as being positive:

  • This is good for Java, at least the perception of Java in the marketplace. Fair or not, there are many people who equate business success with quality (just ask your friendly SharePoint administrator). A nose-diving Sun stock price did not do much for people's perception of the viability of Java as a platform going into the future. Oracle's stewardship should improve this dramatically.
  • Like IBM, Oracle has always done a much better job than Sun actually making money on Java. Of course one could speculate endlessly on the reasons why (one invariably hears the fuzzy term "marketing"), but the fact remains: Sun executives chased the buzzword of the day while Oracle executives made money. In what reminds me of Apple in the late 90's, this is not uncommon in "R&D-oriented" companies; they just don't seem to learn how to sell the technology very well.
  • Solaris. Long viewed as one of the best flavors of Unix (featuring DTrace and ZFS, to name a few cutting-edge technologies), Solaris is the other crown jewel that Oracle picked up in the merger. In the conference call following the announcement, Larry Ellison specifically named Solaris as one of the reasons for the move. Since both Oracle and Weblogic already run on Solaris, owning the OS itself opens up some possibilities for Oracle.
  • Having followed Oracle's acquisition of BEA, I was generally impressed by the fact that Oracle did not automatically favor its own product lines over BEA's. In fact, a lot of careful thought seemed to go into which technology Oracle would adopt going forward. I hope the same will be true for Sun.

And now the less positive:

  • Consolidation. Consolidation is usually a good thing for vendors (at least the winners), and not so much for customers. There is, of course, less choice and inevitably some "cool stuff" that you wanted to last forever winds up in the dustbin.
  • MySQL. The MySQL community is unlikely to be very happy about the merger, given its traditional positioning as a cheaper alternative the the dominant database vendor. Personally speaking (and I'm no expert on the database market), I think that MySQL occupies a different end of the market than Oracle does, one which the the database giant would be foolish to ignore. Oracle is likely to keep selling Oracle database to its "Fortune 500" customers while also selling MySQL support to lower-end customers running LAMP stacks. The good news is that MySQL will remain a light-weight database. The bad news is that "enterprise features" are likely to fall off the development roadmap.
  • Glassfish. Sun was doing some very interesting work with Glassfish, and it's hard to say what will happen to the project in the wake of the Oracle purchase. Will it simply get nuked in favor of Weblogic? Glassfish has not yet seen huge adoption in the marketplace, so it may not have the same argument in favor of it that MySQL does. There is a big question mark hanging around its neck now--which is a shame because Glassfish is the kind of light-weight JEE server that could really be a game-changer if marketed properly.
  • Hardware. Sun is still very much a hardware company (at least in terms of revenue); Oracle is not. It's hard to say what will become of some of Sun's high-end hardware business after the acquisition. Personally, I think that Oracle will try to sell it off to a more hardware-oriented company in order to mitigate the cost of the buy.

Of course, this is all just speculation, and it is fun to speculate at times like these. One thing, though, is for sure: in the face of a bad economic recession, the market for enterprise technology will continue to consolidate.

Syndicate content