Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

When writing web scripts...

Name: Anonymous 2009-12-12 22:01

Do you maintain super strict 80 columns only rule?

Do you let it slide a little?

Do you try to keep 80 columns but if a single line goes way over you leave it like that?

Name: Anonymous 2009-12-12 22:06

120 columns are a loose guide for me. I let it slide a little if it goes a little over. I refactor the code if it goes way over.

Name: Anonymous 2009-12-12 22:09

There's no reason to go over, when you can have your editor enforce it.

Name: Anonymous 2009-12-12 22:11

I've got a line in my script for cleaning user-input strings that goes like this:

$string =~ s/[\x{fdd0}-\x{fdef}\x{fffe}\x{ffff}\x{1fffe}\x{1ffff}\x{2fffe}\x{2ffff}\x{3fffe}\x{3ffff}\x{4fffe}\x{4ffff}\x{5fffe}\x{5ffff}\x{6fffe}\x{6ffff}\x{7fffe}\x{7ffff}\x{8fffe}\x{8ffff}\x{9fffe}\x{9ffff}\x{afffe}\x{affff}\x{bfffe}\x{bffff}\x{cfffe}\x{cffff}\x{dfffe}\x{dffff}\x{efffe}\x{effff}\x{ffffe}\x{fffff}]//g;

I don't think there's anything I can do about it.

Name: Anonymous 2009-12-12 22:12

>>4
Go sit in the corner and think about what you did wrong. And no juice for you.

Name: Anonymous 2009-12-12 22:14

>>5
Why so cryptic? If I knew what I had done, obviously I would have fixed it. So clearly, I don't know what the hell you are talking about.

Name: Anonymous 2009-12-12 22:17

what the hell lrn 2 regex

Name: Anonymous 2009-12-12 22:29

>>4
What is that supposed to filter?

Name: Anonymous 2009-12-12 22:41

>>8
Characters that could be used to bypass a spam filter. I lifted it off someone else's code. (´∀`∩)

Name: Anonymous 2009-12-12 22:46

>>1
I just don't write web scripts.

>>4
Type: man perlre
Now, type: /character classes
Finally, read that until your expression is not so goddamn ugly.

Name: Lisp 2009-12-12 22:48

>>4
Might I recommend PHP's str_replace function? It would be much faster than that shitty Perl regex, and you could store each character on its own line in an array.

Name: Anonymous 2009-12-12 22:52

>>11
Regexps aren't specific to perl

Name: Lisp 2009-12-12 22:56

>>12
But he's clearly using Perl and its sluggish regex engine.

Name: Anonymous 2009-12-12 23:08

Name: Anonymous 2009-12-12 23:10

>>10
Type that where?

I'm no programming expert. I just code stuff for fun as a hobby.

Name: Anonymous 2009-12-12 23:13

>>15
You know what, don't even bother.

Name: Perl 2009-12-12 23:18

>>14
Everything Perl does is right, therefore any deviation in PHP must be a flaw.

Name: Anonymous 2009-12-12 23:24

>>17
Everything PHP does is wrong, therefore any deviation in PHP must be an improvement.

Name: Anonymous 2009-12-12 23:45

>>16
Hey, don't be a jerk. You could have just told me about manual pages. Took me a bit, but I found it.

So I could replace most of these with [[:ctrl:]] ? I'm not sure what most of these character classes cover exactly. Is there a list somewhere?

Name: Anonymous 2009-12-12 23:58

>>19
Yes.

Name: Anonymous 2009-12-13 0:18

Does this make sense? Will is also remove \n ?

$string =~ s/[^[:print:]]//g;

Name: Anonymous 2009-12-13 1:10

>>19
No I mean if it isn't obvious to you it's probably a waste of your time (and def. a waste of mine to explain further) and no one else is going to be maintaining your code anyway so fuck it.

And before asking stupid questions like >>21 read ALL the damn words. It's covered or referred to.

Name: Anonymous 2009-12-13 1:36

>>22
It isn't all covered.

It's not obvious to me at first, okay, but I'm not entirely stupid and unable to learn. In what world does attempting to learn more about regex translate into having to maintain my code? No one's asking you to maintain my code, aside from that snippet, you have not even seen my code.

Quit thinking your the only person on this board capable of answering my queries, you might be knowledgeable, but most certainly not special.

Also, >>21 cannot be answered by man perlreg. It is incredibly cryptic.

I was only able to figure it out by using this program I found called RegexBuddy, which by the way is fucking awesome.

Don't change these.
Name: Email:
Entire Thread Thread List