将0(零)附加到grep匹配引用(Appending 0 (zero) to a grep match reference)
TL;博士
我想在grep搜索的第一个反向引用(
\1
)的末尾添加一个0
。 我如何区分它与第十个反向引用(\10
)。
在bbedit中使用grep ,我想用字符串的一部分和零替换字符串的一部分。
例如,查找并替换字符串的这一部分:
195.22.126.x
在这个字符串中:
195.22.126.x - - [13/Jul/2018:19:16:49 -0200] "GET /file.txt HTTP/1.1" 301 243
部分字符串的一部分和零:
195.22.126.0
如果我想用“y”替换字符串那部分末尾的“x”, grep代码将如下所示:
Find: ^(\d+\.\d+\.\d+\.)x Replace: \1y
但是如果我想用“0”(零)替换“x”,程序会尝试提取第十个匹配,而不是在第一个匹配中添加零,因为
\10
看起来像是“第十个匹配”,不喜欢“第一场比赛和零比赛”。那么如何将一个零附加到grep匹配?
请注意,我不能简单地将“x”替换为“0”,因为字符串中还有其他“x”。 因此我必须匹配字符串的正确部分。
tl;dr
I want to add a
0
at the end of the first backreference (\1
) from a grep search. How can I differentiate this from the tenth backreference (\10
).
Using grep in bbedit, I want to replace a part of a string with a part of that part of a string and a zero.
For example, find and replace this part of a string:
195.22.126.x
in this string:
195.22.126.x - - [13/Jul/2018:19:16:49 -0200] "GET /file.txt HTTP/1.1" 301 243
with part of that part of a string and a zero:
195.22.126.0
If I wanted to replace the "x" at the end of that part of a string with a "y", the grep code would look like this:
Find: ^(\d+\.\d+\.\d+\.)x Replace: \1y
But if I want to replace the "x" with a "0" (zero), the program tries to extract the tenth match, instead of appending a zero to the first match, because
\10
looks like "tenth match" to it, not like "first match and a zero".So how do I append a zero to a grep match?
Please note that I cannot simply replace "x" with "0", because there are other "x"s in the string. Therefore I have to match the correct part of the string.
原文:https://stackoverflow.com/questions/51332643
最满意答案
你使用带有插图的图层列表,以避免内圈从外圈潜伏,如下所示:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <stroke android:width="4dp" android:color="@android:color/holo_red_dark" /> </shape> </item> <item> <inset android:inset="4dp"> <shape android:shape="oval"> <stroke android:width="4dp" android:color="@android:color/holo_green_dark" /> </shape> </inset> </item> </layer-list>
您可以像这样设置按钮的大小和背景:
<Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="100dp" android:background="@drawable/red_green" />
它看起来像这样:
You use a layer list with insets in order to avoid the inner circle to lurk out from the outer circle, like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <stroke android:width="4dp" android:color="@android:color/holo_red_dark" /> </shape> </item> <item> <inset android:inset="4dp"> <shape android:shape="oval"> <stroke android:width="4dp" android:color="@android:color/holo_green_dark" /> </shape> </inset> </item> </layer-list>
You set the size and background of the button like this:
<Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="100dp" android:background="@drawable/red_green" />
It then looks like this:
相关问答
更多-
尝试绘制多个圆圈,但两个圆圈都与一条线连接(Trying to draw multiple circles but both circles connect with a line)[2022-12-29]
从CGContextAddArc()文档: 如果当前路径已包含子路径,Quartz会添加一条将当前点连接到弧的起点的线。 如果当前路径为空,Quartz会创建一个新的子路径,其起点设置为弧的起始点。 因此,您必须首先“移动到”圆圈的初始点: CGContextMoveToPoint(context, center.x + CGFloat(cos(startAngle)) * radius, center.y + CGFloat(sin(startAngle)) * radius) CGContextAddA ... -
这可能是寻找的东西 //track mouse position on mousemove var mousePosition; //track state of mousedown and up var isMouseDown; //reference to the canvas element var c = document.getElementById("myCanvas"); //reference to 2d context var ctx = c.getContext("2d"); //a ...
-
你没有在任何事情上调用svg.select() 。 您需要选择要追加的元素,然后选择要追加的所有元素。 这将创建一个选择,您可以将数据与data函数绑定到该选择。 然后你可以调用enter ,并使用append调用来描述enter上的行为。 您正在调用data并在选择之前enter 。 例: var g = svg.select('svg').selectAll('g') .data(array) .enter().append('g') .append('circle') .att ...
-
形状有多个圆圈(Shape with multiple circles)[2023-09-30]
你使用带有插图的图层列表,以避免内圈从外圈潜伏,如下所示:CSS中有多个完美的圆圈(Multiple perfect circles in CSS)[2023-07-12]
你在语法上有一个小错误,颜色停止应该说明增加的百分比。 浏览器处理2个95%的停止 - 10%为95% - 95%; 10%无效。 您可以通过为过渡设置一个小区域来获得非像素化边缘,例如从95%到97% 你的代码 .panel { background-color: #E67E22; border-color: #E67E22; color: #ffffff; padding: 10px; background-image: radial-gradient(close ...绘制多个圆圈(Plotting multiple circles)[2022-09-17]
您正尝试将cos(th)和cen_x一起添加,并且它们的尺寸不匹配。 您需要使用bsxfun以便正确地广播尺寸。 xunit = bsxfun(@plus, cen_x, r * cos(th)).'; yunit = bsxfun(@plus, cen_y, r * sin(th)).'; plot(xunit, yunit) 您也可以使用rectangle为您绘制圆圈。 您还可以指定FaceColor来填充它们。 positions = [centroid - (r/2), r + zeros ...假设您在自定义视图中,但它也应该在任何视图中使用OnTouchListener。 使用与视图宽度和高度相同的Bitmap.createBitmap()创建可变位图 使用你的逻辑来获取圆圈的信息,例如你可以使用onTouchEvent()来获取你手指的坐标 使用此信息,您可以使用Bitmap.setPixel()将其保存到位图 可选,onDraw()你可以用Canvas.drawBitmap()绘制你的位图 如果您需要向位图绘制形状,您可以创建一个新的Canvas(位图)并在此画布上绘制:像素将在位图上设置。 ...您必须将Style中的Canvas.Left和Canvas.Top属性绑定到用作项容器的ContentPresenter 。 Style由ItemContainerStyle属性应用:拖动多个圆圈中的一个(Dragging one of multiple circles)[2023-09-13]
您应该使用处理程序访问目标节点 d3.select(this) 而不是circle.这是一个简单的解决方案: http : //jsfiddle.net/vupt3/1/ 因此,在mouseUp上,您只需将当前绘制的路径存储到数组中。 然后,如果需要,您可以稍后访问和操作这些环。 // path we are currently drawing var path = null; // array to store paths (so paper.js would still draw them) var circles = []; function onMouseDrag(event) ...相关文章
更多- grep 零宽断言
- 使用grep和正则来分析Web服务器日志
- Becoming a data scientist
- Create a Bootable MicroSD Card
- Drupal Forums instead of phpBB or vBulletin: A casestudy
- Become a Master Designer: Rule Three: Contrast, Contrast, Contrast
- pychseg - A Python Chinese Segment Project - Google Project Hosting
- Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years
- The content of element type "package" must match "...
- A5营销访谈:卢松松和你聊新媒体运营那些事
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)