
02-10-2006, 21:32
|
|
|
|
חבר מתאריך: 17.05.05
הודעות: 7,321
|
|
חשבתי שאתה מכיר ביטויים רגולריים אבל עכשיו אני רואה שלא...אז תסתכל על הדף הזה למידע נוסף:
http://www.php.net/manual/en/refere...tern.syntax.php
שים לב לזה:
ציטוט:
The third use of backslash is for specifying generic character types:
\d
any decimal digit
\D
any character that is not a decimal digit
|
קוד:
SELECT * FROM artist WHERE artist REGEXP '\d' ORDER BY artist DESC
בנוסף לאפשרות הנ"ל אפשר גם להשתמש בביטוי [0-9] שמבטא מספרים בלבד:
קוד:
SELECT * FROM artist WHERE artist REGEXP '[0-9]' ORDER BY artist DESC
מה שכתוב בעמוד שהבאתי לך:
ציטוט:
|
Matches any character that is (or is not, if ^ is used) either a, b, c, d or X. A - character between two other characters forms a range that matches all characters from the first character to the second. For example, [0-9] matches any decimal digit. To include a literal ] character, it must immediately follow the opening bracket [. To include a literal - character, it must be written first or last. Any character that does not have a defined special meaning inside a [] pair matches only itself.
|
ועוד משהו חשוב - בשאילתה שלך בחלק האחרון בפיסקת ה-ORDER BY, לא כתבת DESC או ASC. אני לא בטוח אם זה חשוב לכתוב או לא כי יכול להיות שיש ברירת מחדל מסויימת (שהיא ASC או DESC) במידה ולא כותבים את אופן הזמנת הרשומות.
עריכה:
יכול להיות שצריך לכתוב את ה-REGEXP אחרי שם הטור...
זאת אומרת ככה:
קוד:
SELECT *, artist REGEXP '[:digit:]' FROM artist ORDER BY artist DESC
למרות שהוספת ה-REGEXP בפיסקת ה-WHERE היא נכונה לפחות לפי עמוד זה:
http://dev.mysql.com/doc/refman/4.1...-libraries.html
לכן אני לא מבין ממש למה זה לא הצליח לך, אז נסה בדרכים האחרות שהראתי לך למעלה ותגיד מה יצא לך...
נערך לאחרונה ע"י DCD בתאריך 02-10-2006 בשעה 21:49.
|