« first day (619 days earlier)      last day (3173 days later) » 

8:58 AM
.{2}
 
9:48 AM
morning
 
Morning
 
hi, i know you :P
 
oh?
 
i was previously know as foobar, i changed my nick, i'm friend of CS
remember? :D
 
lol, ok
 
9:54 AM
i have a question
$data = preg_replace('@\s*:\s*@', ':', $data);
i want to strip spaces this way, but only if ":" is placed between two strings
say /boundary1.*?\s*:\s*.*?boundary2/
 
@Mario I guess you need to define "string"
 
what's the best/most concise way to do it?
 
like you're already doing?
If it ain't broke, don't fix it.
 
@HamZa sup! check the above regex ^
 
(?<=\S)\s*:\s*(?=\S)
@Mario ^ something like this?
 
9:56 AM
or \S\K
But then you run into trouble when the spaces are at boundaries of end of lines.
 
@Unihedron hehehe, too cryptic for your average regexer :P
 
i meant not "any" string
but literal "boundary1" and "boundary2"
as in /boundary1.*?(\s*:\s*).*?boundary2/
 
@Mario Oh then you will need to use the \K trick by @Unihedron
 
what's that :D
 
boundary1\K\s*:\s*+(?=boundary2)
 
9:58 AM
/boundary1.*?\K\s*:\s*(?=.*?boundary2)/s
 
testing :P thanks
(anyway if you were wondering, i'm not trying to hide myself to anyone. i changed my nick because i find annoying chat logs being indexed by google)
 
Otherwise just use groups:
/(boundary1.*?)\s*:\s*(.*?boundary2)/s
Replace with:
$1:$2
@Mario ofc I remember :)
 
;)
 
@Mario Why does logs getting logged matter? :P
Everything you post here is CC3.0 anyway.
 
@Unihedron It's those crappy nasty scrappers that annoy me...
 
10:01 AM
yea^
it's slightly more complex, i forgot to mention that multiple : can be between boundaries
:   :   :     boundary1    foo   :   bar    :   baz     : abc : cba     boundary2   :    :    :
->
:   :   :     boundary1    foo:bar:baz:abc:cba     boundary2   :    :    :
performance isn't a requirement, i can execute preg_replace multiple times
 
Eh... You expect to work that with just one regex? It's simpler to do multiple passes.
 
yup, that's what i thought :D
 
I think it's possible with one regex but it will be quite complex with \G and \K magic
 
Haven't fully woke up yet, what's \G again?
looks like the anchor on first sight
 
@HamZa in this case i'd prefer something simpler to maintain
 
10:08 AM
@Unihedron Anchor, match if it's at the previous position
 
Oh, yeah that's it, thanks
I could set up a regexbot in here when I finish javabot :P
 
haha, quite a nice idea. If only I had time, I would probably helped out :)
 
It's going to use one of the ChatExchange libraries because I'm too lazy to reinvent the wheel, especially since I'm one of the people who built that wheel.
 
@Unihedron do you know @capricasix ?
 
@Mario that's the javascript bot yes
in JavaScript, 30 secs ago, by Unihedron
!!>"mu" + "ah"*10 + "a!!"
in JavaScript, 32 secs ago, by Caprica Six
@Unihedron "muNaNa!!"
 
10:13 AM
:P
so guys you are suggesting to run this (boundary1.*?)\s*:\s*(.*?boundary2) multiple times
 
hmm... You can do one more step for extra precision so it doesn't blow up
one sec, gotta bring up the demo to verify that it's not stupid
 
:D
 
I've been attempting that meta regex golf challenge on PPCG, it's driving me nutz
My solution is 31 char, all entries must be of 1 - 29 bytes inclusive!!
 
Something like this @Mario?
 
Would had preferred \h or \s over " ".
But it's great!
 
10:19 AM
yea, I just wanted less to type lol
and not using /x so..
 
:D awesome
 
eh... if you write "boundary2" somewhere between the two tags it kind of ignores the boundaries.
em... w???
 
'cause the spaces after the first boundary2 are still before boundary2?
 
you could always use a negated group instead of \S
 
10:21 AM
I thought we only get rid of spaces when it's surrounding colons.
 
(unoptimised)
(?:boundary1 *|(?!^)\G)(?:(?!boundary2)\S)*\K * (?=[^\n\r]*?\b\s+boundary2)
oh colons
why did a space get there? oh well.
(?:boundary1 *|(?!^)\G)\S*\K *: *(?=[^\n\r]*?\b\s+boundary2)
and replace with :
 
LOL
[^\n\r] -> \N?
 
is this a 'thing'?
great if it does
 
'cuz... I think this isn't linux text :P
yep... pcre
 
ok, cool
 
10:24 AM
in JS and py-re it's just literal N
 
yea, it's really specific, but ok
 
:P
 
handy
 
 
1 hour later…
11:31 AM
@Unihedron are you using chrome with Delimunate?
 
@HamZa maybe, but regex101 has dark theme
 
@Unihedron wuuuuuuuuuuuut TIL
It's not mentioned in the faq... http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean
Well I don't know everything :P
 
@HamZa \N for non-newline char (linux) (pcre - mario said he'd work with PHP), \V for non vertical-whitespace, which might be better but isn't as great for use cases
@HamZa fixing it..
 
@Unihedron are you going to link it here lol?
Haha, a new idea: Creating a reference which refers to chat messages :P
 
:)
PHP 5.1.0+ supports \N and \V, along with perl-re
@HamZa Doesn't sound like a good idea, should I create new SO selfie?
wants rep farm
 
11:36 AM
@Unihedron haha, fine by me. Let's hope there won't be haters/closers...
 
my assembly is online, so I don't worry...
in Tavern on the Meta on Meta Stack Exchange Chat, 1 min ago, by bjb568
YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY! SNOW DAAAAAAAAY! NO SKEEEEEEWL!
 
Well you could ask and answer at the same time. I guess if you posted a nice answer it would stay alive :)
Link it here when you finish
 
That's what a "selfie" is in SOlang :P
 
TIL v2
 
Hi there...i have a question: do you know very good page, where i can learn JS RegExp?
 
11:44 AM
@PDKnight Oh hi it's you again! :)
 
Yeah, it is :D
 
I don't, sorry. @HamZa ping
 
MDN regex?
Not sure if it's complete enough...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
A quick glance, I guess it is for starters.
 
Great! (+1)
thanks, man
 
Welcome
 
12:07 PM
so guys, that regex worked, but i have an exception now
/(START.*?)\s*:\s*(.*?END)/ms
this works
START don't remove spaces here-> : <-here START but do here-> : <- here END END
basically it should select only the innermost START END boundaries
i guess i need to use the (?: thingy
(?!START.*?)(START.*?)\s*:\s*(.*?END) <- fail :(
(?!START)(?:.*?)(START.*?)\s*:\s*(.*?END)(?:.*?)(?!END)
 
12:25 PM
 
Linked in Reference, under "escape sequences".
> You can accept your own answer in 2 days
>:(
 
oh yea, that's a restriction on self answers
 
@Jerry how about this? regex101.com/r/wV7fF5/1 it seems working, but highlight is a bit weird
how i feel in this room:
 
it sure looks weird lol, let's see
I'm at work right now, sorry :s
got a few deadlines >~<
 
no prob :P
 
12:36 PM
Not sure what you were thinking about when you wrote the regex, but it works if you do the replacement $1:$2
at least as long as there's 1 : in the part to be stripped of spaces
 
I'll help ya! What's the problem?
 
clearly, i had/have no clue about anything regex :D
 
I'm still bound to the previous regex of link :D a bit slow, but the optimisation can be worked on a bit if the regex is made longer
 
@Unihedron thanks :D so, this works /(START.*?)\s*:\s*(.*?END)/ms
but i want to select only innermost \s*:\s*
basically START notthis : notthis START butthis : butthis END END
 
that above link does exactly that
on the second line there are two boundary1 and two boundary2
 
12:40 PM
@Jerry i know, but i want to try an easier approach, something i can try to understand xD
 
that's different :D
hmm, well, if there's only 1 : that should be feasible
 
you have max two START, yes
START START START this : will : never : happen END END END
START START max : depth : is : two END END
 
this is the simplest I can think of: (START\s+\S+)\s+:\s+(\S+\s*END)
 
I want a hammer!!
 
@Jerry woa, i don't understand why it doesn't match the first START
 
12:48 PM
There is no room to match another START in the regex, unless you can have like START START : END END in which case the inner spaces will be removed to get START START:END END
 
thanks for your help guys
 
oh, I used \s+ change them to \s* if spaces might be absent
 
i think i get how it works
you guys should make regexconsulting.com and make some monyz
2
clearly. not saying i have monyz, but when i'll get rich i will hire this room entirely
:D
 
Freelance writing regexes? ... Nah, I think they rather post "gimme the regex" questions on the main site.
cuz screw performance and optimal regexes, people who need regexes are most of the time letting go of the right approach and doesn't know what these are anyway.
 
1:04 PM
you are describing me, basically
:D
anyway, have a try on codementor.io
 
1:17 PM
hmm, when I play super mario though, I always try to get everything; especially with the newer versions where you have super coins to collect in each world :3
 
Ultimate perfectionist :)
I haven't played video games in a while, but when I play super mario I try to beat it as quick as possible, even though I started from the very beginning and have no clue what the tricks are.
 
Hi
When these got introduced?
@Unihedron
wow, i love super mario .
 
@AvinashRaj Perl 5.10 and PCRE 7.2 was published with this "new feature" back in 2007 June, where PHP implemented PCRE 7.2 as default support back in 2007 Nov. Java 8 was released with this as "new feature" just back in 2013! — Unihedron 11 secs ago
Hello!
 
catch 15 reps from mine . :-)
 
thanks! :P
 
1:22 PM
2007 June?
 
That's the first release. The official stable Perl 5.10.0 was on December 18th 2007.
It's actually pretty old, just under-documented.
 
so we failed to update this feature on our canonical question for the past 3 or 4 years.
 
2 hours ago, by HamZa
It's not mentioned in the faq... http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean
Well I don't know everything :P
 
works so far: regex101.com/r/qQ6hL5/2 but not with the last piece
 
1:30 PM
@Mario there you have multiple : within the code. You can't use that in this case
 
how?
it worked, no?
 
you would replace only 1 instance of <space>:<space>
here's the 'tough' one modified to the current boundaries lol link
 
i do that recursively
ie, multiple preg_replace
i don't care if it's crap, as long i can read the regex :P
 
Oh recursion~
 
(\{\s*\S+)\s+:(.*\})
this seems to work
i'm failing hard
it doesn't work xD
(\{\s*\S+\s*):\s+(.*\})
/me gives up and writes a char by char parser
 
1:46 PM
to parse or to use regex... that is the question
2
totally not being shakespear
 
ahah
 
@Mario Try this for a modified version of yours then: regex101.com/r/qQ6hL5/4
that will allow you to loop over the replacement
wait no, ignore that
err, considerably longer... (\{\s*(?:[^:\s]*:[^:\s]*\s+)*\S+)\s+:\s*(?=[^{}]*\})
 
@Jerry well, this works
 
but ensures that you don't replace where it shouldn't and allows multiple replacements without making other things break
at least for as far as I can see right now
ok, I need to go home now. will be back later
 
ty for your help
 
1:56 PM
np
 
i'm seriously considering to make a char by char parser
 
that's called... a finite state machine.
So nope, you're not inventing any algorithms, it's already there.
 
 
1 hour later…
3:19 PM
24
Q: Collapse and Capture a Repeating Pattern in a Single Regex Expression

CSᵠI keep bumping into situations where I need to capture a number of tokens from a string and after countless tries I couldn't find a way to simplify the process. So let's say the text is: start:test-test-lorem-ipsum-sir-doloret-etc-etc-something:end This example has 8 items inside, but say ...

maybe ^ ?
 
@CSᵠ ?
Great answer +1'd
 
@Unihedron read the transcript, seemed appropriate
not sure if it fits what @Mario wants
 
lol I think they built a finite state machine already
 
:)
 
 
4 hours later…

« first day (619 days earlier)      last day (3173 days later) »