Tutorial for using Regx

Is there a tutorial for using Regx in search ?

This is a great help for regex in general:

Also, ChatGPT will build perfect regex queries at your request.

4 Likes

There’s a chapter in Mastering Scrivener in which I try to explain RegEx in laymans terms. With examples and a series of handy Regexes for writers.
I use RegEx101 for testing exclusively…

2 Likes

And free resources, now I cant pay by book

But normal use by non programmer people, using in search scrivener?

If your go to ChatGPT and use the free version, just ask the bot something like:

I want to search for places where I used the name Joe within three characters of the number 62. Please create a regex search that I can use in Scrivener.

ChatGPT will give you the follwing reply:

Sure, here’s the regex search pattern you can use in Scrivener:

\bJoe\d{0,3}62\b

This pattern will match any instance of the word “Joe” followed by up to three digits and then the number 62. The \b at the beginning and end of the pattern ensure that the search only matches whole words and not partial matches within other words.

2 Likes

Regular Expression Tutorial - Learn How to Use Regular Expressions is, as the name suggests, more of a tutorial resource for learning RegEx compared to RegEx101, which is also a great resource for testing and understanding the elements of specific expressions.

Scrivener on Windows uses a particular RegEx syntax from Qt that is based on Perl, though it doesn’t support all the same expressions. Lookbehind is rather limited.

From this example, I’d say ChatGPT isn’t quite there. :wink: It described the functionality of its proposed expression all right, but it isn’t what you specified. “‘Joe’ followed by up to three digits and then the number 62” is an interesting interpretation of “Joe within three characters of the number 62”…!

3 Likes

Do you find a practical use by wwriter about RegX? Coud you please show me examples .

Do you mean why would writers use RegExes?

RegExes are poweful Search and Replace operations, so, when you want to do that, you can use Regular expressions.

Examples are:

  • Find text between quotes: dialogue.
  • Find specific words near to the same words
  • Finding adverbs ending with ‘ly’
  • Finding different spellings of the same word
  • Finding common spelling mistakes
  • Finding phrases beginning with ‘there is’ or ‘there are’
  • Finding phrases using -ing words with was or were
  • Finding words starting with vowel and find if is has ‘an’ in front of it and visa verse
  • Find numbers under 21, you ought to write out in words
  • Find two of the same words next to each other
  • Find paragraphs with n or more characters
  • Find unnecessary verbs used with ‘to’
  • Find a number of sentences starting with the same word
5 Likes

Excellent :+1:
Do you know short course to learn Reg?

5 Likes