searching files for regular expressions
1 post
• Page 1 of 1
searching files for regular expressions
Sometimes you want to look for APL code in text files.
The user command ]find can be used to do that.
If you give it a simple string to search it will, by default, look for that string in all the .dyalog files in your current SALT workdir, that is the first folder listed when you do
If you wish to look into a different folder you can use the -folder= modifier to specify it.
If you wish to use different file extensions you can use -types=abc,def,etc to specify them.
For example, to find ABC in text (.txt) files in folder \temp:
]FIND can also search using regular expressions. To do so you use the switch -regex.
For example to look for code where a name starting with 'GUI' is assigned you could use
Sometimes you may find hits in text and comments. If this is a problem you can use ]FIND with the following expression - here I want to find ABC not in comments and not within text:
You can replace ABC by the regex of your choice.
The user command ]find can be used to do that.
If you give it a simple string to search it will, by default, look for that string in all the .dyalog files in your current SALT workdir, that is the first folder listed when you do
- Code: Select all
]settings workdir
If you wish to look into a different folder you can use the -folder= modifier to specify it.
If you wish to use different file extensions you can use -types=abc,def,etc to specify them.
For example, to find ABC in text (.txt) files in folder \temp:
- Code: Select all
]Find ABC -folder=\temp -types=txt
]FIND can also search using regular expressions. To do so you use the switch -regex.
For example to look for code where a name starting with 'GUI' is assigned you could use
- Code: Select all
]find GUI.*?← -regex
Sometimes you may find hits in text and comments. If this is a problem you can use ]FIND with the following expression - here I want to find ABC not in comments and not within text:
- Code: Select all
]Find "('[^']*'|⍝.*$)?(?(-1)(*SKIP)(?!)|ABC)" -regex
You can replace ABC by the regex of your choice.
- DanB|Dyalog
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group