简体   繁体   English

使用正则表达式进行 Github 搜索

[英]Github search using regex

Is there any way to search code in a github repo using regular expressions?有没有办法使用正则表达式在 github 存储库中搜索代码?

Currently, I clone the repo and search.目前,我克隆了回购和搜索。

But I want to type something like但我想输入类似

s/foo/gi

and find all occurances of foo in the code:并在代码中找到所有出现的 foo :

foo.create
foo.extend
fooBar
barFoo
bar.foo

Is this possible?这可能吗? Am I missing something in the docs ?在文档中遗漏了什么吗?

Livegrep允许对〜千兆字节的源存储库进行交互式正则表达式搜索。

现在可以使用GitHub 代码搜索

Using the keyword "OR"?使用关键字“OR”?

foo.create OR foo.extend OR fooBar OR barFoo OR bar.foo

edit: Oops, I answer next to your needs.编辑:糟糕,我在您的需求旁边回答。 sorry.对不起。

Since it's a Git repo, why not just clone it locally, and then use git grep with one of it's regex options?:既然它是一个 Git 存储库,为什么不直接在本地克隆它,然后将git grep与其中一个正则表达式选项一起使用?:

git grep [-w | --word-regexp]
         [-E | --extended-regexp] [-G | --basic-regexp]
         [-P | --perl-regexp]

So maybe something along the lines of所以也许是一些类似的东西

$ git clone repo
$ git grep -w foo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM