小编use*_*977的帖子

正则表达式匹配所有内容,直到最后一次出现/

使用正则表达式(Ant中的replaceregexp)如何匹配(然后替换)从行的开头到最后一次出现的斜杠的所有内容?

我需要的是从以下任何一个开始:

../../replace_this/keep_this

../replace_this/replace_this/Keep_this

/../../replace_this/replace_this/Keep_this

把它们变成这个:

what_I_addedKeep_this

看起来它应该很简单,但我没有得到它.我已经制作了正则表达式,它将识别从那里到行尾的最后一个斜杠和匹配,但我需要的是一个匹配从行的开头到最后一个斜杠的所有内容,所以我可以将它全部替换掉.

这是一个Ant构建文件,它读取一堆.txt文件并转换它在其中找到的任何链接.我只想使用replaceregexp,而不是变量或属性.如果可能的话.

regex ant

8
推荐指数
2
解决办法
2万
查看次数

Jquery用于图像映射区域形状上的工具提示

我已经有了这个工作,使用我发现的一些jquery示例,在悬停图像映射时创建自定义工具提示.

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>

<script>
    $(function() {
        $( document ).tooltip();
    });
</script>


<img src="http://blahblahblah" alt="HTML Map" border="0" usemap="#image" class="map"/>

<map name="image">
    <area shape="rect" coords="19, 138, 177, 161" title="Popup Message" />
    <area shape="rect" coords="19, 178, 314, 192" title="Another Popup Message" />
    <area shape="rect" coords="23, 203, 304, 217" title="A Third Popup Message" />
</map>

<label for="userid">Your userid:</label><input id="userid" title="This Popup Message Appears in the Right Place">
Run Code Online (Sandbox Code Playgroud)

当我将鼠标悬停在图像映射区域上时,它会弹出屏幕左上角的工具提示,而不是鼠标指向的位置.它出现在每个形状的相同位置.

对于其他元素,例如我在图像下方包含的"标签"演示,工具提示会出现在标签的正确位置.

我已经尝试根据我在这里看到的内容添加位置信息,但是我添加的任何内容都没有效果或者它使代码无效而我什么也得不到.如果我添加此位置信息,我看到没有变化:

$( document ).tooltip({ 
    my: "right center", at: …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery jquery-ui

6
推荐指数
1
解决办法
8081
查看次数

使用Ant替换文件名中的所有下划线?

使用Ant任务执行此操作的最佳方法是什么:

从一堆文本文件开始,其名称如下:

Filename_With_Underscores.txt

Another_Filename_With_Underscores.txt

Yet_Another_Filename_With_Underscores.txt
Run Code Online (Sandbox Code Playgroud)

把它们变成这个:

Filename+With+Underscores.txt

Another+Filename+With+Underscores.txt

Yet+Another+Filename+With+Underscores.txt
Run Code Online (Sandbox Code Playgroud)

我实际上需要更改每个文本文件所包含的同名文件夹,也就是说,从这个文件夹/文件结构开始:

Filename_With_Underscores/Filename_With_Underscores.txt
Run Code Online (Sandbox Code Playgroud)

把它变成这个:

Filename+With+Underscores/Filename+With+Underscores.txt
Run Code Online (Sandbox Code Playgroud)

但如果我知道如何重写文本文件名,我可以处理.

我会知道如何用文件内容中的加号替换所有下划线,使用replaceregexp,但我该如何对文件夹和文件名本身这样做呢?

我过去曾使用映射器重写文件夹和文件名,例如:

 <target name="dita_wrap" description="Wraps each file in a folder with the same name as the file, copies all to new location">
    <copy todir="output" verbose="true">
    <fileset dir="source"
    includes="*/*.dita" />
     <regexpmapper handledirsep="true" from="^(.*)/([^/]*)\.dita$"
     to="\1/\2/\2.dita" />
    </copy>
</target>
Run Code Online (Sandbox Code Playgroud)

然而得到类似的东西来捕获和替换文件名中的每个下划线,无论可能有多少下划线,都是在逃避我.有什么建议?

ant

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

JQuery 根据下拉菜单中的选择更改值

我尝试使用 JQuery 创建一个下拉菜单,然后根据人们在菜单中选择的内容更改搜索输入元素上的某个值。

到目前为止,我已经弄清楚如何确定我需要改变的价值。我还了解到,如果有人从菜单中进行任何选择,它会将搜索输入值更改为一个特定值:

<div> 
 <form action="setColor" method="post">
   <fieldset>
     <label for="color">Select A Color</label>
       <select name="color" id="color">
           <option>Blue</option>
           <option selected="selected">Red</option>
           <option>Yellow</option>
      </select>
   </fieldset>
  </form>
</div>


<script> 

  $(function() { 
   $('select[name="color"]').change(function() {
     $('input[name="ancestorId"]').val("9999");
   });
 });

</script> 
Run Code Online (Sandbox Code Playgroud)

我现在需要的是根据菜单选择设置值的东西,匹配如下:

Blue = 9999
Red =  8888
Yellow = 7777 
Run Code Online (Sandbox Code Playgroud)

我仍在查看示例并继续尝试,但有点卡住了。任何建议表示赞赏。

html javascript jquery

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

标签 统计

ant ×2

javascript ×2

jquery ×2

css ×1

html ×1

jquery-ui ×1

regex ×1