473,499 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java Script problems


I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.

Can someone help me to explain this expression?
Jan 15 '08 #1
9 1692
On 1/15/2008 3:35 PM, Tuy Solang wrote:
I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.

Can someone help me to explain this expression?
It's a regular expression that means

2 letters must occur one or more times and creates a backreference to them.

Then, there must be a dash, followed by 2 or 3 more letters, and creates
a backreference to those as well.

It sets that pattern to the variable pat_piece, presumably to do a match
or replace later on.

/ - starts regular expression
( - starts grouping for backreference
\w - matches alpha character
{2} - Requires exactly 2 alpha characters
) - closes backreference group
- - Just a dash
\w{2,3} - says there must be at least two letters, but three is ok too
/ - ends the regular expression
; - unnecessary cluttering of the end of the line, IMHO

Hope this helps,
~A!

--
anthony at my pet programmer dot com
CLJ FAQ:
<URL: http://www.jibbering.com/faq/ >
Jan 15 '08 #2
Tuy Solang wrote:
I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.

Can someone help me to explain this expression?
It is an erroneous Regular Expression literal, and I would be surprised if
there was no error in Netscape 7.1. `\w' specifies a word character, and
the following `{2}' means two of them. Then follows a `+' which means the
preceding expression must occur one or more times. However, the `{2}'
quantifier must not be followed by the `+' quantifier. For a minimum number
of characters you have to use the {n,} quantifier, with n being 2 here.

However, it is also possible that you were looking for `(\w{2})+' instead,
which would mean one or more occurrences of two consecutive word characters,
or that the `+' was meant literally (designating a check move) in which case
it should have been `\w{2}\+'. It is not clear what exactly is meant here
because AFAICS the matched string would not be a valid token as defined in
the PGN Specification.

http://developer.mozilla.org/en/docs...Objects:RegExp
http://www.very-best.de/pgn-spec.htm
PointedEars
Jan 15 '08 #3
SAM
Tuy Solang a écrit :
I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.
<http://www.evolt.org/article/Regular_Expressions_in_JavaScript/17/36435/>
Can someone help me to explain this expression?
I think that is to search a group of
2 alphanumeric characters eventually several times
followed by '-'
followed by 2 or 3 alphanumeric characters

Any string with at least 5 characters
and among which 2 or 3 last ones are separated from the others by one -
and these others always by number pair

ab-p2
ab1o-p12
zstr45-hh
zstr45-hhn

--
sm
Jan 15 '08 #4
Thomas 'PointedEars' Lahn wrote:
Tuy Solang wrote:
> I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.

Can someone help me to explain this expression?

It is an erroneous Regular Expression literal, and I would be surprised if
there was no error in Netscape 7.1. [...]
I installed, saw, and was surprised. The script engine of Netscape 7.1
[NS71] accepts the above literal, indeed, and interprets it as if `\w{2}+'
was `\w{2,}'. That bug is apparently fixed since Netscape 7.2 [NS71].

BTW, since support for the Netscape suite and browser will cease on
2008-02-01 [ANN] , it might be a good idea to get the Netscape installers
while you still can; I downloaded Communicator 4.78, Navigator 6.23, 7.1,
7.2, 8.1 and 9.0.0.5 today.

[NS71] Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)
Gecko/20030624 Netscape/7.1 (ax)

[NS72] Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2)
Gecko/20040804 Netscape/7.2 (ax)

[ANN]
http://blog.netscape.com/2007/12/28/...-web-browsers/
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jan 16 '08 #5
SAM
Thomas 'PointedEars' Lahn a écrit :
Thomas 'PointedEars' Lahn wrote:
>Tuy Solang wrote:
>>gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

Can someone help me to explain this expression?
It is an erroneous Regular Expression literal, and I would be surprised if
there was no error in Netscape 7.1. [...]

I installed, saw, and was surprised. The script engine of Netscape 7.1
[NS71] accepts the above literal, indeed, and interprets it as if `\w{2}+'
was `\w{2,}'. That bug is apparently fixed since Netscape 7.2 [NS71].
Question :
how to do to get a word with a number pair of characters ?

(because I thought that '\w{2}+' was to do it)
I downloaded Communicator 4.78, Navigator 6.23, 7.1,
7.2, 8.1 and 9.0.0.5 today.
where ? thank you

--
sm
Jan 16 '08 #6
SAM meinte:
Question :
how to do to get a word with a number pair of characters ?

(because I thought that '\w{2}+' was to do it)
/(\w{2})+/
Though I'm sure what you mean by "number pair of characters"...

Perhaps you want to have a look at
http://www.regular-expressions.info/tutorial.html

BTW:
According to my Eclipse RegEx plugin /\w{2}+/ is accepted by JDK regular
expressions, but not by any of the other engines offered.

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jan 16 '08 #7
Many thank, Spock.
After I remove the + sign out, it is working.
About the KPGN, we modify the original one a little bit to accomodate
2 or 3 or 4 players. So the board will have either 8x8 or 14x14.
Here is a small sample of KPGN.

1. SB-i1-h2 -Time 00:00:03-00:00:03
2. WB-a6-b7 -Time 00:00:06-00:00:06
3. NK-h14-g14 -Time 00:00:11-00:00:11-Count 1-64
etc...
The game is written in C using TCP/IP. Since there is limited TCP/IP
connection, we decide to write the Java Script and automatically
download to any user homepage. This will allow more
people to watch the game. Both C and Java will be free.

Since we are not good in Java, we just process the KPGN without
checking for legal move or not.
Now, all we need is ftp SDK in C to do the download. I'd been
searching the Internet for a free ftp SDK, but I could not
find one yet. Until then, the player or server have to use other
ftp program to do the job.
Thomas 'PointedEars' Lahn <Po*********@web.dewrites:
Tuy Solang wrote:
I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.

Can someone help me to explain this expression?

It is an erroneous Regular Expression literal, and I would be surprised if
there was no error in Netscape 7.1. `\w' specifies a word character, and
the following `{2}' means two of them. Then follows a `+' which means the
preceding expression must occur one or more times. However, the `{2}'
quantifier must not be followed by the `+' quantifier. For a minimum number
of characters you have to use the {n,} quantifier, with n being 2 here.

However, it is also possible that you were looking for `(\w{2})+' instead,
which would mean one or more occurrences of two consecutive word characters,
or that the `+' was meant literally (designating a check move) in which case
it should have been `\w{2}\+'. It is not clear what exactly is meant here
because AFAICS the matched string would not be a valid token as defined in
the PGN Specification.

http://developer.mozilla.org/en/docs...Objects:RegExp
http://www.very-best.de/pgn-spec.htm
PointedEars
Jan 16 '08 #8
SAM
Gregor Kofler a écrit :
SAM meinte:
>Question :
how to do to get a word with a number pair of characters ?

(because I thought that '\w{2}+' was to do it)

/(\w{2})+/
That catches the first 2, 4, 6, 8, ..., letters of each word
BTW:
According to my Eclipse RegEx plugin /\w{2}+/ is accepted by JDK regular
expressions, but not by any of the other engines offered.
BBEdit prefers (\w{2})+

\W(\w{2})+.jpg

--/img1.jpg /img001.jpg /01.jpg "img2.jpg
--
sm
Jan 16 '08 #9
In comp.lang.javascript message <uh***********@verizon.net>, Tue, 15 Jan
2008 20:35:22, Tuy Solang <so****@verizon.netposted:
>
I download four scripts that are used to display
Khmer PGN for Khmer Chess. It works fine with Netscape 7.1
on MS Millenium, but it gave me an error(Java Script console)
with Netscape 8.1 on MS XP. Here is the line :

var pat_piece=/(\w{2}+)-(\w{2,3})/;

I am familiar with C, but I have no clue with the above expression.

Can someone help me to explain this expression?

It gave you an error, which would have been some sort of message. That
message is supposed to guide you at least part-way towards determining
what that error is.

Therefore, you should have posted here the exact error message.

<FAQENTRY>
Section 2.3, which is too large and needs to be subdivided, needs to
say, at about paragraph 4, that where germane it is necessary to give
the exact error message (and an English translation) and a clear
indication of the alleged location of the error.

The final sentence of 2.3 para 1 is not sound English.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jan 16 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
24721
by: Steven Green | last post by:
I have a java app at work I used when I had Windows 98 and never had a problem. I did a clean install of Windows XP and of course Java was not included. I went to Sun, download Java 2 Runtime...
4
12053
by: Laura P | last post by:
Hi, I wasn't sure whether this should be posted in the Java are or in a Solaris thread, so I shall post it in both. Sorry for the duplication. I am new to Solaris and am having trouble...
2
6880
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
18
2863
by: Mickey Segal | last post by:
On comp.lang.java.programmer we are discussing problems created for Java programs by pop-up blockers (in the thread "showDocument blocked by new microsoft pop-up blocker"). Our problem is that...
9
2370
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
36
2012
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y...
2
6918
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
4
6167
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.