473,769 Members | 2,240 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 1711
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_Express ions_in_JavaScr ipt/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 bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.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*********@we b.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.javas cript 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.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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
24742
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 Environment, SE v 1.4.2 and Java 2 Runtime Environment SE v 1.4.1_01. The Java app will not work with WinCP. I have installed the Windows XP Service pack 1, IE service pack 1 and I have downloaded Netscape and Opera. The same problem happens in...
4
12085
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 running a long Java command from a shell script. Firstly, my Solaris (8) / Java setup. Mu machine already had Java 1.2
2
6928
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 a type mismatch. It is positively because of the boolean(java primitive)parameter. It goes fine if I change this parameter to int or String. This inteface has a lot more methods which works fine, it is just the
18
2901
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 Java's showDocument method, which opens new browser windows, is blocked by some pop-up blockers. The showDocument method is blocked even if the user clicked a button in a Java program to call showDocument. As a result, a type of user-initiated...
9
2395
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 that creates non-JavaScript problems that can be fixed using JavaScript. With the Microsoft update installed, Java applets (as well as other content such as Flash videos) are unable to receive user input until an activating click or key press....
36
2091
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 mouse coordinates into a variable that i can do real math on. So far, i can do math on the values "read" and that result goes into a "variable" that is useful *only* for display. If i try "int" in that math, the values are then zero for everything...
2
6966
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
4
6193
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 generated are written to a log file. A project team working in the same company as me here would like to use this loading utility. They write UI applications for Windows using Java. They were able to launch the Python script from within Java by...
0
9424
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3968
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 we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.