473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Regexp question: ()'^% etc => _

Q
Hi,

I want to make a 'plain' filename from a database entry..
So eg:

Test (for ^@@\example-etc.)%&#.html
==>
Test_for_example-etc._.html

Pleaaaaaaaase???
:-)))

Regards,
Marco
Mar 9 '06 #1
5 1191
d
Q" <do********@hotmail.com> wrote in message
news:44***********************@news.xs4all.nl...
Hi,

I want to make a 'plain' filename from a database entry..
So eg:

Test (for ^@@\example-etc.)%&#.html
==>
Test_for_example-etc._.html

Pleaaaaaaaase???
I use something like this:

$s=preg_replace("/[^A-Z0-9_\-\.]+/i", "_", strtolower($s));
$s=preg_replace("/_{2,}/", "_", $s);

which does what you want :)

dave
:-)))

Regards,
Marco

Mar 9 '06 #2
Did you have a question or are you just giving everyone a demonstration
of funny looking filenames? Are we supposed to pick our favorite? Or
are you trying to say that you currently have a database full of
examples of corrupt filenames and you want to create a similar database
with filenames that are not quite as corrupt but are still funny
looking? Or are you designing a new syntax of regexp that specilized in
finding files who's names match a specific pattern? Or are you creating
a new programming language with the fewest number of reserved words
possible?

Or are you creating a new operating system that uses a crytic command
prompt/syntax designed for use in scifi movies? Because if so, it looks
good so far but make sure you have an "override" command so that the
hero can bypass the villans security lockout at the very last minute to
open the gas chamber and save the girl! Also use IMPACT 72pt for all
text.

-Robert

Mar 9 '06 #3
Q
huh?
"rlee0001" <ro*********@hotmail.com> schreef in bericht
news:11**********************@j33g2000cwa.googlegr oups.com...
Did you have a question or are you just giving everyone a demonstration
of funny looking filenames? Are we supposed to pick our favorite? Or
are you trying to say that you currently have a database full of
examples of corrupt filenames and you want to create a similar database
with filenames that are not quite as corrupt but are still funny
looking? Or are you designing a new syntax of regexp that specilized in
finding files who's names match a specific pattern? Or are you creating
a new programming language with the fewest number of reserved words
possible?

Or are you creating a new operating system that uses a crytic command
prompt/syntax designed for use in scifi movies? Because if so, it looks
good so far but make sure you have an "override" command so that the
hero can bypass the villans security lockout at the very last minute to
open the gas chamber and save the girl! Also use IMPACT 72pt for all
text.

-Robert

Mar 9 '06 #4
Q
@Robert:

FYI:
Was only trying to find "a" way to create readable (and valid) filenames in
combination with apache rewrite rules...
The funny chars were only there so the guru's knew to "group" them to one _

Ok?

@d:
THANKS!!!! :-)

"rlee0001" <ro*********@hotmail.com> schreef in bericht
news:11**********************@j33g2000cwa.googlegr oups.com...
Did you have a question or are you just giving everyone a demonstration
of funny looking filenames? Are we supposed to pick our favorite? Or
are you trying to say that you currently have a database full of
examples of corrupt filenames and you want to create a similar database
with filenames that are not quite as corrupt but are still funny
looking? Or are you designing a new syntax of regexp that specilized in
finding files who's names match a specific pattern? Or are you creating
a new programming language with the fewest number of reserved words
possible?

Or are you creating a new operating system that uses a crytic command
prompt/syntax designed for use in scifi movies? Because if so, it looks
good so far but make sure you have an "override" command so that the
hero can bypass the villans security lockout at the very last minute to
open the gas chamber and save the girl! Also use IMPACT 72pt for all
text.

-Robert

Mar 9 '06 #5
d
"rlee0001" <ro*********@hotmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Did you have a question or are you just giving everyone a demonstration
of funny looking filenames? Are we supposed to pick our favorite? Or
are you trying to say that you currently have a database full of
examples of corrupt filenames and you want to create a similar database
with filenames that are not quite as corrupt but are still funny
looking? Or are you designing a new syntax of regexp that specilized in
finding files who's names match a specific pattern? Or are you creating
a new programming language with the fewest number of reserved words
possible?

Or are you creating a new operating system that uses a crytic command
prompt/syntax designed for use in scifi movies? Because if so, it looks
good so far but make sure you have an "override" command so that the
hero can bypass the villans security lockout at the very last minute to
open the gas chamber and save the girl! Also use IMPACT 72pt for all
text.
Having "safe" filenames can be very beneficial. I use them all the time as
a way to make very human-readable URLs, without sprawling masses of crap. I
know not everyone in this group feels the need to have properly-manicured
URLs, but I do.

Do you hate the md5() function, too? All that does is turn a
perfectly-readable message into 32 characters of crap. I suppose we should
ditch that and wipe out the creator's family with attack helicopters.

I didn't think his question prompted such a response. It's a perfectly
reasonable question.
-Robert

Mar 9 '06 #6

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

Similar topics

1
by: denisb | last post by:
hello all, for a search engine, I'm looking for a regexp than can do the job it is just (!) a 's' problem (frequent in french) : I have a field 'thesaurus' in a table MySQL (3.23.56) ; I...
1
by: python_charmer2000 | last post by:
I want to match several regexps against a large body of text. What I have so far is similar to this: re1 = <some regexp> re2 = <some regexp> re3 = <some regexp> big_re = re.compile(re1 +...
19
by: Magnus Lie Hetland | last post by:
I'm working on a project (Atox) where I need to match quite a few regular expressions (several hundred) in reasonably large text files. I've found that this can easily get rather slow. (There are...
5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
6
by: Mark Johnson | last post by:
Is there a shorthand for this: <xsl:when test="$day2 or $day2 or $day2">
4
by: Jon Maz | last post by:
Hi All, I want to strip the accents off characters in a string so that, for example, the (Spanish) word "práctico" comes out as "practico" - but ignoring case, so that "PRÁCTICO" comes out as...
7
by: Csaba Gabor | last post by:
I need to come up with a function function regExpPos (text, re, parenNum) { ... } that will return the position within text of RegExp.$parenNum if there is a match, and -1 otherwise. For...
11
by: HopfZ | last post by:
I coudn't understand some behavior of RegExp.test function. Example html code: ---------------- <html><head></head><body><script type="text/javascript"> var r = /^https?:\/\//g;...
1
by: bdbeames | last post by:
I have a form where I would like to perform some validation using a javascript function. I cant' figure out the RegExp. function is_number(target) { target.value = trim(target.value); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.