I am garbage at regex. could anyone help me with this please.
I'm checking that the string does not contain ": " but also want to make sure that string isn't only whitespace, it's for indentation so it's quite likely that the line could start with 2 or more spaces.
/^(?:(?!: ).)+$/
It works fine at the top level, just don't know you sort the spaces at the start of the line.
Thanks
Anthony Perez
Jesus I hate how convoluted regular expressions are.
Samuel Nelson
I think I got it
/^(?:(?!: ).*\S)+$/
Asher Martinez
No :( that ignores the ": " on subsequent indented lines
Hudson Miller
imo regex isnt the right tool for this job. a simple if condition would be much easier
Evan Taylor
make two separate regexes you spastic
Ian Campbell
it has to be done in one hit
This can only be regex
Angel Carter
or do something like ^(\s+|.*: .*)$ and check that it doesnt match
Xavier Martin
why do you have those two conditions? context will help is help you
Andrew Wilson
^(.*: .*| +)$ If it matches then you fail
Bentley Thomas
try this ^(?!^(\s+|.*: .*)$).*$
Hudson Thomas
It's for stylus selectors, to run an action when return is pressed. I need to know that the line is not
property: value
The only unique thing about these strings is that they contain ": " which the original I posted deals with but with the original if you wanted to insert a blank line at any indent level other than the top it runs the indent action again, this is why I need to make sure the string that is being tested isn't only whitespace
Lincoln Reyes
first, checked
second, thanks but no dice
property: value // should not match // should not match
div // should match div // should match
Cooper Reed
works for me
Kayden Green
It does! sorry, I had my regexr set to javascript.
Thanks a lot user, I owe you a beer
Daniel Smith
Bonus round, can this be modified to allow the ": " if the string starts with "@" ?
Ryder Barnes
sure, ^((?!^(\s+|.*: .*)$).*|@(?!^\s+$).*)$
Logan Carter
Absolute hero. thank you!
Camden Rodriguez
I GO NOW TO FOR EXPLAINING OF REGULAR EXPRESSION.
MANY CONSCRIPT SAY TO ME, "IVAN, PLEASE TO BE EXPLAINING OF REGULAR EXPRESSION. IS HAVE VISUAL APPEARANCE OF NOISE OF LINE OR BAD PERL PROGRAM OF CALIFORNIA CAPITALISM"
REGULAR EXPRESSION IS STRONG STRING MATCHING TECHNOLOGICAL SISTEMA FROM TIME OF COLD WAR. IS SIMPLE.
AT BASIC OF REGULAR EXPRESSION IS AVTOMAT OF FINITE STATE. COMPILE OF REGEX IS GENERATE LIST OF STATE FOR AVTOMAT OF NONDETERMINISM. IS USING REWRITE RULE TO CONVERT AVTOMAT OF NONDETERMINISTIC FINITE STATE TO AVTOMAT OF DETERMINISTIC FINITE STATE.
REGULAR EXPRESSION SISTEMA IS CONSIST OF THREE OPERATORS: STAR OF KLEENE, CONCATENATE OF STRING, UNION. MANY REGEX IMPLEMENTATION, HE IS ADD OF ADDITIONAL OPERATORS. PLUS SYMBOL OF ONE OR MORE CHARACTER IS USUAL.
TO USE REGEX, IS HAVING NEED OF EXTRACT SUBSTRING. FOR THIS, REGEX IS HAVING PARENTHESES FOR MAKING THE GROUP OF CAPTURING.
SOME REGEX HE HAVE MAKING OF NAMES OF GROUP, LIKE IN BAD LANGUAGE PYTHON OF ITALIAN FASCISM. NAMED GROUP OF CAPTURE IS MAKING LIFE OF PROGRAMMER EASIER, SO REAL PROGRAMMER HE NOT USE THIS FEATURE. IF REGEX HARD TO WRITE, HE SHOULD BE EQUALLY HARD TO READ. THIS IS PROUD MARXIST-LENINIST PRINCIPLE OF EQUALITY
TRUE COMRADE ALSO ALWAYS ESCHEW USE OF MAKING THE COMMENT INSIDE OF REGEX. COMMENT INSIDE OF REGEX IS CRUTCH OF CAPITALIST WEAKNESS.
CONCATENATE OF LARGE REGEX FROM MANY SMALL WARIABLES IS CAPITALIST PLOY TO HIDE PROUD LABOR OF REGEX WRITING WORKERS. SINGLE LONG REGEX IS STRONG TESTAMENT TO ACHIEVEMENT OF PROLETARIAT.
TO WRITE REGEX IS POWERFUL SKILL. LIKE DRIVE TANK. BUT ALSO IS PRACTICAL SKILL, SIMILAR TO REPAIR OF KALASHNIKOVA. WHEN YOU ARE MASTER OF MAKING TO REGEX, MANY COMRADE THEY WILL LOOK TO YOU IN AWE. ALL CONSCRIPT IS WANT TO BE COMRADE OF POWERFUL WRITER OF STRONG AVTOMAT OF REGULAR EXPRESSION.
NEXT WEEK, I EXPLAIN MAKING TO SYSTEM OF DISTRIBUTED. THIS IS NOT NEED TO BEING COMPLEX TECHNIQUE OF CALIFORNIA ACADEMIC.
Gabriel Wood
You better bookmark regex101 if you need to use regex regularly, it will save your brainlet and your sanity. Nothing dumber than spending precious brainpower sorting regex match groups by squinting at fucking symbols and guessing.
Kevin Jenkins
FOR MAKE AVTOMAT OF DETERMINISM FROM REGULAR EXPRESSION IS ALGORITHMIC SISTEMA TOO ADVANCE FOR TO TEACH TO CONSCRIPT PHP "DEVELOPER", BUT APPROPRIATE FOR UNDERGRADUATE COURSE IN SCIENCE OF COMPUTER.
I GO NOW FOR TO EXPLAIN.
MAKE AVTOMAT OF DETERMINISM OF REGULAR EXPRESSION IS TYPICAL PROCESS OF TWO STEPPING: FIRST STEPPING TO MAKE AVTOMAT OF NON-DETERMINISM OF REGULAR EXPRESSION. SECOND STEPPING TO MAKE AVTOMAT OF DETERMINISM OF AVTOMAT OF NON-DETERMINISM.
FOR MAKE OF AVTOMAT OF NON-DETERMINISM IS SIMPLE SISTEMA OF FIVE RULE.
FOR NOTATION OF ASCII, "( )" IS BEING STATE OF AVTOMAT, "--> ( )" IS BEING STATE OF STARTING, and "(( ))" IS BEING STATE OF ACCEPTING.
RULE: FOR CHARACTER OF a, AVTOMAT OF --> ( ) -- a --> (( ))
RULE: FOR CHARACTER OF EMPTY (YEST), AVTOMAT OF: --> ( ) -- є --> (( ))
RULE: FOR CHARACTER OF a CONCATENATE CHARACTER OF b, SUCH AS REGULAR EXPRESSION OF "ab", MAKE AVTOMAT OF: --> ( ) -- a --> ( ) -- є --> ( ) --> b --> (( ))
RULE: FOR CHARACTER OF a SOYUZ CHARACTER OF b, SUCH AS REGULAR EXPRESSION OF "a|b", MAKE AVTOMAT: /-- є --> ( ) -- a --> ( ) -- є --\ -->( ) (( )) \-- є --> ( ) -- b --> ( ) -- є --/
RULE: FOR STAR OF KLEENE, SUCH AS REGULAR EXPRESSION OF "a*", MAKE AVTOMAT OF:
/--- ( ) -- є --> (( )) \---> ------- є ----> ----/
BY CONCATENATE OF THESE AVTOMATS, WORKER CAN MAKE AVTOMAT OF NON-DETERMINISM TO REPRESENT ALL REGULAR EXPRESSION. THIS IS LIKE HOW CONCATENATE TOGETHER OF MANY WORKERS IS FORM POWERFUL SOYUZ OF PARTY, YOU SEE IT?
NEXT, I GO TO EXPLAIN HOW AVTOMAT OF NON-DETERMINISM IS TRANSFORM TO AVTOMAT OF DETERMINISM. THIS IS HAVING EFFECT OF IMPROVE PERFORMANCE.
Charles Walker
Is regex the ultimate casual filter?
Jace White
I think most people just don't learn them properly, they probably are doing some intro to web dev shit and need some complicated regex to match an email string and have no idea how to build one, look online and see this complicated fucking mess that handles everything and they just give up and don't bother to learn.
if you actually learn it from scratch like this commie above is spouting they make a lot of sense and are pretty easy when you see them as finite state machines
Matthew Collins
Go on.
Blake Myers
> IF REGEX HARD TO WRITE, HE SHOULD BE EQUALLY HARD TO READ. Fucking preach brother. If I just spent the last 30 minutes getting this monstrosity to work, I don't see why everyone else should be able to just walk up and understand it just like that. You gotta deserve it it you wanna touch it.