如何设置替换命令,如果目标将动态HREF正在添加是 [英] How to set replace command if target will dynamic href is comming

查看:96
本文介绍了如何设置替换命令,如果目标将动态HREF正在添加是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的HTML:

desc=desc=<a target="_blank" href="http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&amp;id=27000000000000002519&amp;search=">A. P. (DIR Series) Circular No. 46 dated June 14, 2005</a>

这里的id =值的变化和corporatelaws或directtaxlaws

here id= values changes and corporatelaws or directtaxlaws

String   k = replace ( desc, "<a target=\"_blank\" href=\"http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=RULES&amp;id=35000000000000001648&amp;search=\">", "");

在说明我得到的HTML我有替代命令我,所以我从锚标记目标挑数据删除链接是动态的,其中id不同,我能够取代链接文本,其目标是

In desc I'm getting HTML I have replace command I have to remove link so I'm pick data from anchor tag target is dynamic where id varies I'm able to replace linking to text whose target is

<一个href=\"http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=RULES&id=35000000000000001648&search=\" rel=\"nofollow\">http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=RULES&id=35000000000000001648&search=\\

但是当过目标的变化,我的意思是说,如果ID改变,它不会取代链接文本。

but when ever target changes, I mean to say if id changes, it doesn't replace link as text.

请告诉我如何获取和设置ID值,这样,如果目标将是动态的,我们完全可以替代链接文本。我是新来的Andr​​oid编程。

Please tell me how to get and set the id values so that if target will be dynamic we can replace link as text. I'm new to android programming.

String str = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&amp;id=27000000000000002519&amp;search=";
int indexoff = str.indexOf("id=");
int indexofl = str.indexOf("&amp;search=");

String strsub = str.substring(indexoff + 3, indexofl - indexoff - 3);
String strstaticstring = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&amp;id=" + strsub + "&amp;search=";
String k = desc.replace(strstaticstring, "");

我想这一个,但我不知道如何挑选corporte或directtaxlaws会来。

i have trying this one bUt i dont know how to pick corporte or directtaxlaws will come ..

推荐答案

试试这个方法:

String str ="";
if(desc.contains("http://www.taxmann.com/corporatelaws/")==true)
{
 str = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&amp;id=27000000000000002519&amp;search=";
}

if(desc.contains("http://www.taxmann.com/directtaxlaws/")==true)
{
 str = "http://www.taxmann.com/directtaxlaws/fileopencontainer.aspx?Page=CIRNO&amp;id=27000000000000002519&amp;search=";
}

if(desc.contains("http://www.taxmann.com/corporte/")==true)
{
 str = "http://www.taxmann.com/corporte/fileopencontainer.aspx?Page=CIRNO&amp;id=27000000000000002519&amp;search=";
}

或者你可以上/基地分割你的字符串,并检查它的话corporte,directtaxlaws等。

or you can split your string on the bases of "/" and check it for words corporte,directtaxlaws etc.

String str = "http://www.taxmann.com/corporatelaws/fileopencontainer.aspx?Page=CIRNO&amp;id=27000000000000002519&amp;search=";      
 string[] strarr = str.Split('/');

在strarr [3] U将得到corporatelaws值SA串用它来承包整个字符串desc中替换

in strarr[3] u will get corporatelaws value sa string use it for contracting whole string for replacing in desc

这篇关于如何设置替换命令,如果目标将动态HREF正在添加是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆