PDA

View Full Version : Javascript Wildcards



Atolar
04-10-2006, 03:51 AM
Does javascript have a wildcard character such as * or % ? If so, how do you use it? If not, what alternatives are there to use?

ddadmin
04-10-2006, 04:33 AM
If yo mean in terms of text manipulation, yep, via Regular Expressions. You may want to read up on Introductory Guide to regular expressions. (http://www.javascriptkit.com/javatutors/re.shtml)

p,s: I've shortened your sig, since the length of it made it easy to confuse it with your actual posts.

Atolar
04-10-2006, 04:59 PM
Thanks for the link, i'll be sure to check it out!

Twey
04-10-2006, 05:34 PM
A more extensive guide to regex can be found at http://www.regular-expressions.info/.

bardonw
12-02-2009, 05:58 PM
Last night, I put the finishing touches on a plugin for JXtension which allows you to use wildcards to search a string. It gives the user the capability to turn wildcard expressions into regular expressions. I know that many people have wondered if you could use wildcards in JavaScript, therefore I plan on adding this plugin to JXtension 1.1. On the other hand, if you don't think that it would be useful, perhaps I will leave it as a plugin. Since the goal of JXtension is to help the webmasters develop code faster, what do you think? Do you think that this would be a useful feature? Please reply here or take the poll and reply on my forum by clicking here (http://gotochriswest.com/forum/viewtopic.php?f=4&t=387&start=0).

bardonw
03-01-2011, 10:54 PM
Since jPaq has replaced JXtension, jPaq is the library that now gives you the ability to search strings with wildcard characters. Here are the three examples that are on the jPaq home page (http://jpaq.org/):

alert("Where in the world is Carmen Sandiego?".findPattern("C*n"));
alert("Christopher West".replacePattern("(<*>) (<*>)", "p", "$2, $1"));
alert("2 to the 64th is 18446744073709551616.".findPattern("#{3,}", "ol"));