regex - find an import in code with regular expression -
i have import error somewhere in code can't find it. can use search function in editor (sublime text) search regular expression in files inside project. search terms 'import' , 'views' in between or before / after, want match line contains these 2 words.
i'm not familiar 'sublime text', following regex
works in 'notepad++':
(.*)(import)(.*)(views)(.*)
now, in line matched, $1
, $2
, $3
, $4
, $5
may used refer text before "import", "import", text between "import" , "views", "views" , text after "views" respectively.
edit - 1
it works 'sublime text' well.
for example, text,
asdf1234 ..import.fghj4567 views...hjkl7890
find (as above):
(.*)(import)(.*)(views)(.*)
replace with:
$2, $4, $5, $3, $1
result:
import, views, ...hjkl7890, .fghj4567 , asdf1234 ..
for text,
asdf1234 views fghj4567 import hjkl7890
find (as above):
(.*)(views)(.*)(import)(.*)
replace with:
$2, $4, $5, $3, $1
result:
views, import, hjkl7890, fghj4567 , asdf1234
edit - 2
it seems working me though:
Comments
Post a Comment