Can you solve this puzzle involving regular expressions?

Click For Summary

Discussion Overview

The discussion revolves around a puzzle involving regular expressions, originally presented in an interview context for a cybersecurity position. Participants explore the challenge of matching specific regex patterns to form coherent words or sentences, with a focus on understanding the implications of the regex syntax.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant seeks assistance in solving the regex puzzle, noting their unsuccessful attempts to match the patterns to form meaningful sentences.
  • Another participant explains the meaning of certain regex components, such as the significance of [^x] and the use of {99} for matching, while also attempting to interpret the first regex line.
  • A participant claims to have found a solution that fits their interpretation of the regex, presenting a sentence that they believe meets the criteria.
  • Some participants express difficulty with the second regex line, specifically regarding the placement of 's' characters and the potential for mismatches.
  • Concerns are raised about the implications of spelling variations, particularly between British and American English, in relation to the puzzle's context.
  • One participant speculates that the regex might be intentionally misleading, suggesting a theme of obfuscation related to security.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the correct solution to the puzzle, with multiple interpretations and approaches presented. Some express confidence in their findings, while others highlight uncertainties and challenges with specific regex lines.

Contextual Notes

There are unresolved issues regarding the exact matching criteria of the regex patterns, particularly concerning the placement of characters and the implications of spelling differences. Some assumptions about the regex's design and intent remain unexamined.

MesonMarcus
Messages
2
Reaction score
0
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:
unnamed.png


.{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...
 
Physics news on Phys.org
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 .
 
  • Like
Likes   Reactions: pbuk
awesome!
 
jedishrfu said:
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.
 
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.
 
jedishrfu said:
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.
Line 2 only depends on 's's and spaces in the right place. It won't match if you use the US spelling for defence, unsurprisingly given the employer :biggrin:
 
But it seemed solving it on paper that a couple of s characters were off According to that regex. I chalked it up to the possibility that the expression was an outlier perhaps designed to be misleading ala obfuscation Aka security thru obscurity.

I as puzzled by the defence spelling too but decided that since BAE is a British company that the spelling was correct. I imagine that would have tripped up a few Americans applying for the job. :-)
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
Replies
1
Views
2K
Replies
7
Views
3K
Replies
41
Views
5K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
1
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 39 ·
2
Replies
39
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K