How Do I Tweak This Javascript Expression?

Jul 23, 2005

I have got a bookmarklet for use with Opera which highlights all
occurrences of some text in the displayed page. I find it very
useful.

Sometimes I need to use two or three different colours for different
keywords I want highlighting on the same page. I have done this by
changing the original word 'yellow' for other javascript colour
words.

I know next to nothig about javascript. So I would ask if anyone
knows how I can tweak this javascript bookmarklet code (see below) in
two sepearte ways:

(1) So that I can select a color from a list. This may be as simple
as changing the caption to say "enter 1 for lime, 2 for yellow," etc.
or it might be cleverer.

(2) This is mutually exclusive with (1). In this case the
javascript would prompt me to enter a javascript colour keyword (like
"yellow" or colour code like "FF00FF").....

View 3 Replies


ADVERTISEMENT

Javascript Regex Expression Challenge

Jul 18, 2006

I am looking out for a regular expression that takes the following format

textfile_20060711_113441.txt

where
textfile = name of the file
2006 = year
07=month
11=day
11=hour
34=minute
41=seconds.
.txt is extension

The file always comes in the same format. however we need to implement checks so that user doesnt enter invalid month/day/hour/minute etc.

I have created the following regular expression
textfile_(?<Year>(?:d{4}|d{2}))(?x)(?<Month>d{1,2})(?<Day>d{1,2})_([01]?[0-9]|[2][0-3])([0-5][0-9])([0-5][0-9]).[a-zA-Z]{3}

Can anyone guide me as to how do i modify this regex to suit my requirement. This regex currently is not able to handle invalid months or days etc.

Also i do not know how to integrate this regex in my javascript. Pointers or examples will be helpful.

View 2 Replies View Related

JQuery :: How To Tweak Pageflip Code

Dec 6, 2011

I'm a flash designer and new to jquery. I've a little experience customizing javascript for html, but for the most part this is new to me (and pretty frustrating, I must say). Glad there's a jquery forum and hopeful that I can get some pointers.

Here's my problem: I am using a terrific bit of jquery code for a custom pageflip effect, however if I put an html link on the same page, it doesn't work. I'm guessing that this has to do with the pageflip code designating the two corners of the "book" to function onClick, however I don't know how to get around this. Here's a link to the code I'm using: [URL]...s there a bit of jquery I can use for a link instead of the traditional HTML tags? Or is there some other way to add a link that won't be interfered with by the pageflip code?

View 2 Replies View Related

Match Entire String (regular Expression & Javascript)

Jul 23, 2005

I'm trying to perform a very simple validation of user input. I
want to verify that the user entered a six-digit string consisting
entirely of numbers. So anything from 000000 to 999999 is considered
valid. The problem that I'm having is getting the validation to work on
the entire string. In other words, 000000 is okay but 000000000000 is
also returning as a match. Here's a quick code block...I have something
along these lines....

/*********************/
<html>
<body>
<INPUT name="txtNumberField" type="text" id="txtNumberField">
<INPUT onClick="fnTestNumberField()" id=Button1 type=button value="Test
Number!" name=btnTest>
<script language=javascript>
function fnTestNumberField()
{
var sNumberValue = document.getElementById("txtNumberField").value;

if (sNumberValue.match(/A[0-9]{6}z/))
{
alert("match");
} else {
alert("no match");
}
}
</script>
</body>
</html>
/******************/

That is failing when I enter 123456 into the textbox. Why, though? I
know I can replace...

if (sNumberValue.match(/A[0-9]{6}z/))

....with something like...

if (sNumberValue.length == 6 && sNumberValue.match(/[0-9]{6}/))

....or I could assign a maxlength to the input box, of course. The thing
is, I really want to know WHY the regular expression isn't responding
as I'd expect. Is there a syntax error somewhere in the code?

View 2 Replies View Related

JQuery :: Slight Tweak To Existing Function?

Dec 18, 2010

I hope you can help tweak a jQuery function...

If you look at this "fiddle":[URL]... (it was written by a friend of mine, Addy Osmani...you probably know him!)

[Code]...

View 2 Replies View Related

JQuery :: Tweak To Tablesorter (filter Table Values)?

Aug 10, 2009

I'm developing a table that'll have dropdown filters above it. However my table has a slight twist in that some columns will have more than one value in them, eg imagine a column with these values:

- UK
- UK
- UK, USA
- UK, Germany
- Germany
- USA

Now when I filter by 'UK' it should show four results - not two. Can anyone give me a few pointers how to do this or point me towards a plugin that might tackle this already? The values will always be comma separated.

View 2 Replies View Related

Jquery :: Parse XML Feed - Tweak My Existing Code To Output The Content Of The First <itunes:subtitle> Entry Under The Link It Generates?

Aug 20, 2011

I'm trying to tweak a small script to pull some data from an iTunes podcast formatted XML feed. Currently, it outputs a link to the most recent actual mp3 file with the episode title as the name (which is great), but I'd also like it to show a description of the episode under the link.Here's the code I have so far:

Code:
jQuery(
function($)
{[code].....

How can I tweak my existing code to output the content of the first <itunes:subtitle> entry under the link it generates?

View 3 Replies View Related

Reg Expression

Sep 23, 2005

I need a regular expression which takes all the numbers off the end of any string but ignores any leading zeros eg:

df6456 = 6456
sdfg024 = 24
scgyd001254 = 1254

View 3 Replies View Related

?: In Regular Expression

Feb 21, 2006

I have seen lot of reg. expession with ?:
For dummy eg
(((XXX)ddd)ff)

The above expression is modified as
(?:(?:(XXX)ddd)ff)

Although both the above expr. gives same result. (RegExp.match() gives
same o/p), most of the places , i have seen second option.

Yes, but different matches r shown (using RegExp.exec())

Is the second expr. most efficient or in particular scenarios?

Any comments???

View 5 Replies View Related

Reg Expression For Currency

May 20, 2006

I need a regular expression to format U.S. currency as 1,215.25 (commas and decimals)...if it is not already in that format. It should also allow a '-' sign as the first character for negative numbers. I have looked in the FAQ and through this group, plus the net and cannot seem to find the right example.

Any pointers or solutions appreciated. Thanks. I found the belowposted in this group:

<script type="text/javascript">
var RgX = /^$(d{1,3}(,d{3})*|(d+))(.d{2})?$/

function NewComma(Q) { Q = String(Q)
return (Q == (Q=Q.replace(RgX, "$1$2,$3"))) ? Q : NewComma(Q)
}

function setFormat(elm){
var frmCurr= NewComma(elm);
alert(frmCurr);
}

setFormat(121525);
</script>

View 3 Replies View Related

JS Does Not Execute The Expression?

Mar 25, 2011

I have the following function:

function sonKare(sayac, oteki) {
var vertical, horizontal = hangiYataySira(sayac, oteki), j, k,
l, m, united, tekRakam, actualV = [], actualH = [],
numaralar = [1, 2, 3, 4, 5, 6, 7, 8, 9], olmayanlar = [];

[Code].....

This is a recursive function. As stated above there is a line which does not work for the second time. What I mean is, it works perfect for the first time and after function calls itself, it doesn't work. Javascript does execute the line above it but just disregards that document.form1.buton.click(); line. I use Firebug for debugging and I checked it many times, when that expression needs to be executed for the second time, JavaScript just ignores it and immediately goes at the end of the function... I just can't figure out why JS does such a thing?

View 4 Replies View Related

Regular Expression Problems

Jun 28, 2006

At the moment my code is like:

function telValid(inString) {
var regexp = /^[0-9 +()]+$/;
return (inString.match(regexp,''));
}

which is use to validate phone numbers (UK at the moment)

this works ok, but wont allow - (Dashes) which i need..

tried doing:

function telValid(inString) {
var regexp = /^[0-9 +-()]+$/;
return (inString.match(regexp,''));
}

View 2 Replies View Related

Regular Expression Replace.

Jan 20, 2007

I am finding it difficult to find a regular expression for following situation(replace)

a b c d = a,b,c d
a b c = a,b c

View 8 Replies View Related

Regular Expression To Get The File Name From A URL?

Feb 5, 2009

regular express to get the file name from a URL?

It has to be flexible in that the extension can be either 4, 5, or 6 chars (.php, .html, .shtml for example) and needs to cater for and whether querystring parameters exist too.

So, both

[URL]

and

[URL]

The regex should return newthread for both.

View 4 Replies View Related

Get Innerhtm Value Using Regular Expression?

Nov 13, 2009

I.E.:

---------------------------
Windows Internet Explorer
---------------------------
<EMBED src=http://www.youtube.com/v/JTmM3jut05Q&hl=en&fs=1& width=500 height=200 type=application/x-shockwave-flash allowfullscreen="true" allowscriptaccess="always"></EMBED>

how can i get "src" value in above code using regular expression?

<object width="500" height="200"><param name="movie" value="http://www.youtube.com/v/JTmM3jut05Q&hl=en&fs=1&"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/JTmM3jut05Q&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="200"></object>

how can i get "src" value in above code using regular expression?

View 6 Replies View Related

Regular Expression For Substring?

Jul 7, 2010

what will be the regular expression for this line:

Code JavaScript:
var id = $(this).attr("href").substring( $(this).attr("href").lastIndexOf('#'), $(this).attr("href").length);

Basically it gets the string after # in href attribute of clicked anchor tag.

View 3 Replies View Related

Regular Expression For A Date?

Aug 26, 2010

I have this expression:

/(19|20)dd/)[- /.](0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])

to detect if my date:

2010-12-15

is valid. It's not working. What do I have wrong?

View 6 Replies View Related

Explorer 5.01 Regular Expression Bug

Dec 30, 2004

When Internet Explorer 5.01 for Windows hits the regular expression:

/(?=<)|>/

it complains about an unexpected quantifier. In fact, it seems to complain whenever I use a lookahead expression. Is there any way around this?

View 2 Replies View Related

Expression() For Netscape/Mozilla?

Aug 16, 2002

I have been looking and looking to no avail.

IE has had, since IE4, the use of:
expression( [function or script expression])
within a style block declaration to dynamically set the value of a css property.
Does Netscape v6+ and/or mozilla have anything of the sort?

Code:
<style type="text/css">
div{position:absolute;
top:expression((document.documentElement.offsetHeight * 0.15) + 'px');}
</style>

View 10 Replies View Related

Alphanumeric Values Only I.e Reg Expression?

Nov 16, 2011

I want the user to enter only alphanumeric(i.e a-z and 0-9) and a "-"(hyphen) in the text field

View 1 Replies View Related

How To Build A Regular Expression On Runtime?

Jul 23, 2005

does anyone know how I can build a regular expression e.g. for the
string.search() function on runtime, depending on the content of
variables? Should be something like this:

var strkey = "something";
var str = "Somethin like this";

if( str.search( / + strkey + / ) > -1 )
{
...
}

View 9 Replies View Related

Comma Delimited Regular Expression

Dec 7, 2006

I need a regular expression that will validate a double quote comma
delimited list where the odd entries are numeric and the even are
alphabetical. Each pair must also be on a separate line. For example:

"1","Peter"
"2","Paul"
"3","Mary"

I've used the following expression to validate comma delimited lists, but
without the double quotes, numeric/alpha pairing and line return
restriction.

^([A-Za-z0-9]?)+([,]s?([A-Za-z0-9]?)+)*$

View 1 Replies View Related

Regular Expression To Match Any Spaces

Oct 9, 2007

Normally I can write regular expressions decently well but for some
reason I am having trouble getting this to work. I am validating form
data and need to throw an error if there are ANY spaces in the field.
abc123 is fine, abc 123 is not. Any character is fine, just not a
space.

View 2 Replies View Related

Regular Expression To Exclude Lines?

Jul 20, 2005

All I'm trying to do is delete the lines which don't contain a particular
string. Actually a filter to edit a log file. I can find and replace a thing
with null, but can't figure out how to find the lines which do not contain
the thing.

Going further, I want to generalize and use a JavaScript variable containing
the decision string, but first I need to worry about the not-within-a-line
problem.

View 26 Replies View Related

JQuery :: Extrac String From A Given Expression?

Apr 15, 2011

Is there an available function in jQuery that would let me extract certain string of characters in a given expression, say I have the expression "2|23|6|niece", i wanted to extract 2,23,6 and niece from the given expresion and assign each in a variable leaving the (" | ") character

View 3 Replies View Related

JQuery :: Regular Expression Validation?

Aug 7, 2009

I would like to validate a textbox that numbers cannot be entered into the text input, how do i do this??? With regular expression??

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved