Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende RegExp Creation | ContentDev Tools
Test UI Features

bookRegExp Creation

12345678910111213141516171819202122232425262728293031
import re # Enter expected input correct_text = r'''print('Example string 1') print('Example string 2') ''' # Enter expected output output = r'''Example string 1 Example string 2 ''' # Set up pattern to search for check_pattern = r'''print(|'Example string 1'|)''' # Set up space replacer with escape character space_replacer = '\|' # RegExp creation reg = '^(((?!' + re.escape(check_pattern).replace(space_replacer, '\ *') + ').)*)$' # Resulting RegExp print('RegExp:') print(reg) # If RegExp found in Input if re.findall(reg, correct_text, re.S) == []: print('--- Input DONE! ---') # If RegExp found in Output if re.findall(reg, output, re.S) == []: print('--- Output DONE! ---')
copy

Set up:

  • correct_text - what should be in the user's input field for the correct result.
  • output - what should be in the user's output field for the correct result.
  • check_pattern - string that you want to check for. Place a space_replacer in all places where the user might enter an indefinite number of spaces.

If RegExp found your pattern in the user's input, you will receive: --- Input DONE! ---

If the pattern is found in the user's output: --- Output DONE! ---

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you explain how the space_replacer works in this code?

What does the reg variable represent in this context?

How does this script check if the pattern is present in the input or output?

Awesome!

Completion rate improved to 1.22

bookRegExp Creation

Desliza para mostrar el menú

12345678910111213141516171819202122232425262728293031
import re # Enter expected input correct_text = r'''print('Example string 1') print('Example string 2') ''' # Enter expected output output = r'''Example string 1 Example string 2 ''' # Set up pattern to search for check_pattern = r'''print(|'Example string 1'|)''' # Set up space replacer with escape character space_replacer = '\|' # RegExp creation reg = '^(((?!' + re.escape(check_pattern).replace(space_replacer, '\ *') + ').)*)$' # Resulting RegExp print('RegExp:') print(reg) # If RegExp found in Input if re.findall(reg, correct_text, re.S) == []: print('--- Input DONE! ---') # If RegExp found in Output if re.findall(reg, output, re.S) == []: print('--- Output DONE! ---')
copy

Set up:

  • correct_text - what should be in the user's input field for the correct result.
  • output - what should be in the user's output field for the correct result.
  • check_pattern - string that you want to check for. Place a space_replacer in all places where the user might enter an indefinite number of spaces.

If RegExp found your pattern in the user's input, you will receive: --- Input DONE! ---

If the pattern is found in the user's output: --- Output DONE! ---

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
some-alt