# Can you solve this puzzle involving regular expressions?

MesonMarcus
can anyone help solve this puzzle regarding regular expressions? I was given this in an interview test from BAE systems cyber security department a few years ago and just came across it again, still haven't managed to get anywhere like an answer. I have tried matching each line of regex to form words but no look. The puzzle is as follows:

.{14}security.{15}
[^s]{3}s [^s]{6}s[^s] s[^s]{12}s [^s]{8}
def
^It'..[ywkni][klmop][zwta]
ce.$jus [^f]*fenc y, it's t ...t Give your answer. This is the best I could get... ...security... bees xxxxxxsx sxxxxxxxxxxxxs xxxxxxxx def It's not ce. jus xfenc y, it's t xxxt but makes no sense... ## Answers and Replies Mentor The idea is to find a line that matches each of the regex strings. [^x] means doesn’t match x and {99} is the number of times to match with * for 0 or more and + for one or more. ^ outside of the [ ] means beginning of the string and$ means the end of the string.

I think the first line matches a string containing the text security

. . . . . . . . . . . . . . s e c u r i t y . . . . . . . . . . . . . . .

the second line matches a line where the 4th character is an s and some more s later on.

I t ‘ s . n o t . . . . . . s e c u r i t y . . . . . . . . . . . . c e .

my attempt yielded the sentence but it doesn’t match all the criteria.

I T ' S _ N O T _ J U S T _ S E C U R I T Y , _ I T ' S _ D E F E N C E .

pbuk
MesonMarcus
awesome!

Homework Helper
Gold Member
I T ' S _ N O T _ J U S T _ S E C U R I T Y , _ I T ' S _ D E F E N C E .
It's not just security, it's defence. works for me.

Mentor
I had trouble with line 2 aka the s not s expression. It seemed not all the ‘s’ characters lined up in my solution although I didn’t test it.

I ll have to try it in AWK, my favorite go to language.