小编Dan*_*owe的帖子

URL 开头有双斜杠?

我目前正在开发一个 chrome 扩展,它允许我下载网页上使用过的字体文件。

\n

当我解析该网站的字体时,我遇到了其中一个字体 URL 的奇怪边缘情况。

\n

对于字体,Freddy规则@font-face如下所示:

\n
@font-face {\nfont-family: \'Freddy\';\nsrc: url("//cdn.shopify.com/s/files/1/0548/8708/8184/t/24/assets/freddy_regular_2-webfont.woff?v=147712666987587936441646682936") format("woff") , \n  url("//cdn.shopify.com/s/files/1/0548/8708/8184/t/24/assets/Freddy_Regular_2.ttf?v=64870238297763773461646682938") format("truetype") , \n  url("//cdn.shopify.com/s/files/1/0548/8708/8184/t/24/assets/freddy_regular_2-webfont.woff2?v=66678714148373221751646682937") format("woff2"); /* Safari, Android, iOS */}\n
Run Code Online (Sandbox Code Playgroud)\n

这破坏了我的脚本,因为双斜杠使其成为无效的 URL(即,如果我按原样将其输入浏览器,则会出现错误)。

\n

所以我想知道 \xe2\x80\x94 这个 URL 开头的双斜杠的目的是什么?如果它看起来是无效的 URL,那么它实际上如何检索字体?

\n

javascript css url font-face google-chrome-extension

0
推荐指数
1
解决办法
946
查看次数

什么是\.在Perl中匹配时的意思是什么?(反斜杠点)

我想知道\.Perl中的字符是什么意思,特别是在匹配表达式中.我知道这\可以成为逃避角色.它只是逃避点吗?或者它还有其他意义吗?

在下面的情况下,我假设,当条件($ARGV[$i] =~ /\./)满足时,变量$Chain没有设置参数$ARGV[$i].我尝试查找有关Perl正则表达式和匹配的信息,但我无法拟合上下文.

for (my $i = 0; $i <= $#ARGV; $i++) {
    if ($ARGV[$i] && ! ($ARGV[$i] =~ /\./)) {
        $Chain .= " " .  $ARGV[$i];
    }
}
Run Code Online (Sandbox Code Playgroud)

regex perl matching

-1
推荐指数
1
解决办法
483
查看次数

无法读取perl中的hash值

在perl代码中,我尝试通过将键和值存储在2个单独的数组中来初始化哈希.要初始化数组,从文本文件中读取数据然后进行处理.

我按照以下语法将键和值存储到哈希中:

@hash {@key} = @值;

当我尝试显示哈希的内容时,我能够单独显示密钥的内容而不显示值.为什么哈希没有采用任何值?怎么解决这个问题?

文本文件

NAME,OWE,RECEIVE
RAM,2000,1000
TEJA,1500,2200
NANDHINI,400,3000
RAGHAV,0,5000
ETHI,100,2500
KESHAV,400,400
Run Code Online (Sandbox Code Playgroud)

以下是我的代码:

$i = 0;
open(FH, "<expenses_details.txt") or die "Couldn't open the file";
%nameo;
while ($line = <FH>)
{
    chomp($line);
    if ($i == 0)
    {
        $i++;
        next;
    }
    ($name, $owe, $receive) = split(',', $line);
    #print "Name is:$name, Owe:$owe, Receive:$receive \n"; 
    push(@names, $name); # Creating name array
    push(@owes, $owe);  #creating owe array
    push(@receives, $receive); #creating receive array
}
close FH;
print "Name array:\n";
foreach (@names)
{
    print …
Run Code Online (Sandbox Code Playgroud)

perl hash

-1
推荐指数
1
解决办法
171
查看次数

在 git 中只提交某些更改的正确方法是什么?

当我处理多个文件时,有时我会处理不同文件对应的不同功能。

我通常做的是:

git status
git add <file/directory 1> # eventually with /* following directory name to commit
                           # the subdirectories rather than the directory itself
                           # (not sure how it works exactly)
git add <file/directory 2>
git commit -a              # here add commit message in editor
[ ... after N commits ... ]
git push (origin master / whatever)
Run Code Online (Sandbox Code Playgroud)

我注意到的是,大多数时候它都能正常工作:提交的文件正是我添加的文件。但是,有时它会提交所有文件。

我做错了吗?

另外,commit -acommit -m 有什么区别?

git

-2
推荐指数
1
解决办法
3232
查看次数

标签 统计

perl ×2

css ×1

font-face ×1

git ×1

google-chrome-extension ×1

hash ×1

javascript ×1

matching ×1

regex ×1

url ×1