Regular Expression to remove space in HTML Tag
Hello All,
My HTML string is like below.
select '<CityName>RICHMOND</CityName>
<StateCd>ABCD CDE
<StateCd/>
<CtryCd>CAN</CtryCd>
<CtrySubDivCd>BC</CtrySubDivCd>' Str from dual
Desired Output is
<CityName>RICHMOND</CityName><StateCd>ABCD CDE
<StateCd/><CtryCd>CAN</CtryCd><CtrySubDivCd>BC</CtrySubDivCd>
i.e. want to remove those spaces from tag value area having only spaces otherwise leave as it is. Please help to implement the same using Regular expression.
Hi,
It's unclear what you want. This site seems to be formatting your message in some odd way.
Post a statement like
SELECT '...' FROM dual;
without any formatting, to show your input, and post the exact output you want friom that, with as little formatting as possible. It might help if you use some character like ~ instead of spaces (just for posting; we'll find a solution that works for spaces).
To remove the text that consists of spaces and nothing else between the tags, you can say
REGEXP_REPLACE ( str
, '> +<'
, '><'
How is this string being generated? Maybe there's some easier, more efficient way to keep the bad sub-wrtings out of the string in the first place.
Similar Messages
-
I have a large file with lots of anchor tags. Many of the anchor tags have no HREF specified and do nothing. They aren't hurting anything, either, but I'd like to get rid of them, leaving the anchor tags that do have HREF alone, and leaving the text between the tags alone. Here's an example: <a>A resident or municipality may seek to vacate 25.01.01</a>.
I've come up with this to identify those tags: <\a>(.)*</\a> and it works, it finds them, but what should I put in the Replace area in order to remove the open/close tags but leave the text as it is?I'm a reg ex idiot. So I use the Search Specific Tag feature whenever I can. See screenshot, hit Replace All. But please do this on a backed-up document to be sure it does what you want.
Nancy O. -
Using Regular Expressions To Remove Characters JDK 1.4
I want to write a regular expression to remove all commas in a string of text.
string is:
1,000
or 1,000,000
I want it to return 1000 and 1000000.
I have tried some but I am just starting with Regular Expressions.
Please Help!Try this tutorial: Linux : Education : Tutorials
Using regular expressions
David Mertz
President, Gnosis Software, Inc.
September 2000
http://www-105.ibm.com/developerworks/education.nsf/linux-onlinecourse-bytitle/6C2B4863702F592B8625696200589C5B?OpenDocument -
Regular Expression for Removing a space after the a... tag?
Hi there,
I'm fairly new to using Regular Expressions, but am in need of one that will help me find all <a...> tags that have a space immediately following that tag and replace it with the exact same tag, but no space following the <a...> tag.
So, for example, a regular expression that will find:
<a href="somelink.html"> Somelink</a>
as well as:
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('sub-nav_button_professional_portal','','images/sub-nav_button_ professional_portal_f2.png',1)"> Somelink</a>
And just remove the space appearing as part of the hyperlink. Does anyone know how to accomplish this?Thought of that, but it would remove spaces from crucial areas of my pages. For example, conditional logic within a script, like:
for (i = 0; i > (a.length - 2); i += 3)
would become:
for (i = 0; i >(a.length - 2); i += 3)
While that wouldn't pose a huge problem, I'm messing up the syntax in order to fix something else, which is why I wanted to go the route of a regular expression. I need to replace all "<a ...> " (space included) tags with "<a ...>" and make sure that the properties within the <a> tag stay in tact. -
Regular Expression to convert URI to HTML link tag
I'm trying to create a method that takes an input string and converts any URIs found in the string to a html link tag.
For example,
String input = "This is a test string. I like http://www.sun.com/ and think you should check out http://java.sun.com/"; The output should contain an html a tag for each URI and use the URI as the text as well.
I need this for a blogging web app i'm working on.
I tried a few things like
import java.util.regex.*;
import java.text.*;
public class test
public static void main(String[] args)
final Pattern p = Pattern.compile("(\\sI\\n|^)(\\w+://[^\\s\\n]+)");
final Matcher m = p.matcher(args[0]);
System.out.println(args[0]);
args[0] = m.replaceAll( "$1<a href=\"$2\">$2</a>");
System.out.println(args[0]);
}Any ideas? Something like this will match "http://www.apple.com/" but not a complex string. I've googled this quite a bit and I'm not very good with regular expressions.Couldn't get your posted regex to work on anything. Try this:public static void main(String[] args) {
String input = "This is a test string. I like http://www.sun.com/ and think you should check out http://java.sun.com/";
final Pattern p = Pattern.compile("(\\s|^)(\\w+://\\S+)(\\s|$)");
final Matcher m = p.matcher(input);
input = m.replaceAll("$1<a href=\"$2\">$2</a>$3");
System.out.println(input);
}It should match any uri, however I recommend replacing \\w+ with a more concrete string like (?:(?:http)|(?:https)|(?:ftp)). Let me know if you have a uri that it doesn't match. -
Regular Expression To Remove Leading While Space
Hii
I have a data like this
20200 Kuala Terengganu
Terengganu
Luala Terengganu
I want to remove the Leading white space in the Second line .Can anybody help me to
write regular expression for this?
I want my result like the following :
20200 Kuala Terengganu
Terengganu
Luala Terengganu
Thanks In Advance
Jim JohnBut there's no difference between two group of lines which you posted. Could you please format your input and desired output with please?
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Regular expression for BBcode list to html list
Hi,
we are migrating BBforum to Jive forum.
BBforums has data which contains BBcode Strings.i found the follwoing code after googled.
public static String bbcode(String text) {
String html = text;
Map<String, String> bbMap = new HashMap<String, String>();
bbMap.put("(\r\n|\r|\n|\n\r)", "<br/>");
bbMap.put("\\[b\\](.+?)\\[b\\]", "<strong>$1</strong>");
for (Map.Entry entry : bbMap.entrySet()) {
html =
html.replaceAll(entry.getKey().toString(), entry.getValue().toString());
return html;
i have BBcode with format like
[list] [*]blue[*]red[*] green[list]
i have to replace this by <ul><li>blue</li><li>red</li>
Can any one sugeest me java regular expression which replace as above
Edited by: 875452 on Jul 31, 2011 8:03 AMModerator advice: Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose.
Then edit your post and format the code correctly.
Moderator action: Moved from Development Tools » General Questions
db -
Regular expression to remove SIDs from list
Hey everyone so I have a script and in it I try to find the current user, as well as the last user. Currently I'm using a regular expression to throw the System account SIDs and other things like that out of the list. However this doesn't seem to be taking
SQL SIDs out of my list ie. ReportServer$LOCAL with the SID S-1-5-80-4264962431-3932693095-1576469926-235475122-2208986020
What's the best way to get only user SIDs?
Here's what I have so far:
$Win32User = Get-WmiObject -Class Win32_UserProfile -ComputerName $Computer
$Win32User = $Win32User | Where-Object {($_.SID -notmatch "^S-1-5-\d[18|19|20]$")}
$Win32User = $Win32User | Sort-Object -Property LastUseTime -Descending
$LastUser = $Win32User | Select-Object -First 1
When I can this it breaks since there is no actual user tied to this SID:
$UserSID = New-Object System.Security.Principal.SecurityIdentifier($LastUser.SID)
$User = $UserSID.Translate([System.Security.Principal.NTAccount])
Thanks for any help!!Start cmd.exe as your domain user and run whoami /user to get your own SID. You will get something like this:
USER INFORMATION
User Name SID
========================= =============================================
DEMOSYSTEM\CustomAccount1 S-1-5-21-3419697060-3810377854-678604692-1000
The last part of the SID, in this case 1000, is called RID. When you create a new user or computer object in your domain, only the RID will be different from your own SID. The RID starts on 1000 and increments as you create new objects.
If you are only interested in user accounts from the same domain as your user, you can use a regex like this, only based on your own SID:
$_.SID -match '^S-1-5-21-3419697060-3810377854-678604692-[\d]{4,10}$' -
Java Regular Expression for double spaces
I am using ([\\s\\s]+) this regex for finding double spaces but if in single segment (Text Line) there exists two or more double spaces then it is finding only one from it .
Matcher m = Pattern.compile( regexp ).matcher(Segment );
while(m.find)
p.println(" ERROR :: Punctuation (Double Dot ) Error");
Suggets solution
Thanks
amitHi,
I understood the question like this:
You have a String, and you want to find if the string have 2 or more than double spaces till the end of the string.
I have attached a sample code for the above problem. Please have a look into it.
public class FindDoubleSpacesInString {
private static final String DOUBLE_SPACE_STRING = "tetett etetete etetete etete et e tet ";
* @param args
* loganathank
* void
public static void main(String[] args) {
String doubleSpaceRegExPattern = "\\s{2,}";
Pattern doubleSpacePattern = Pattern.compile(doubleSpaceRegExPattern);
Matcher doubleSpaceMatcher = doubleSpacePattern.matcher(DOUBLE_SPACE_STRING);
while(doubleSpaceMatcher.find()) {
System.out.println("double space found");
}Please let me know, whether it resolves your problem.
Regards,
Loga -
Regular Expression to Remove Part of URLs
I need to accomplish the following:
Search for all URLs that contain "
http://www.mycompany.com/dept/catalogs/"
and strip off anything past the .../catalogs/"
Basically, I have 3000+ links that begin with "
http://www.mycompany.com/dept/catalogs/"
and I need to strip whatever they may have after the .../catalogs/
piece of the URL.
Anyone know of an automatic way to accomplish this?
Thanks in advance!In what programming environment are you doing this?
In DW's Find/Replace?
If so, then try this carefully on a test page, as I have not
tested it:
Find:
http:\/\/www\.mycompany\.com\/dept\/catalogs\/[^\"]*\"
Replace with:
http://www.mycompany.com/dept/catalogs/"
If you need this in some other environment, let us know.
E. Michael Brandt
www.divahtml.com
www.divahtml.com/products/scripts_dreamweaver_extensions.php
Standards-compliant scripts and Dreamweaver Extensions
www.valleywebdesigns.com/vwd_Vdw.asp
JustSo PictureWindow
JustSo PhotoAlbum, et alia -
Regular expression - removing emails
Hi,
How to use regular expressions to remove email addresses from
html files ?
Thanks in advance.
Maxcxmaxcx wrote:
> Hi,
> How to use regular expressions to remove email addresses
from html files ?
> Thanks in advance.
> Maxcx
Do you want to remove the email address, or to remove the
whole <a>
tag containing same?
Mick -
Stripping HTML thru regular expression(pls help)
Hi all..
I've been trying to use the regular OROMatcher-1.1 expression package downloaded from apache.org.
it works well with my program but i m having problems building correct regular expression to strip off HTML tags.
can any of u help me build an expression tha strips of ALL html tags including those with funny spaces such as:
<a href = "www.here.com">click me</a>
do help pls. i've tried for ages and its driving me madHi,
Wont go into much details but the simplest way to do that would be using XML technology. Try using SAX or DOX whatever you feel comfortable with. I think SAX would be a better choice. For details visit
http://java.sun.com/xml/?frontpage-spotlight
/khurram -
Remove HTML Tags and parse the text out of it
Hi All -
I had a text file with all the HTML Tags on it. I want to parse text out of it. Is there any package available to remove all the HTML Tags from the text.
For example
<HTML><BODY bgColor=#ffffff> This is the text i want to parse.</BODY></HTML>
The result would be: This is the text I want to parse.
The text can be very long and can have many different HTML Tags. I cannot use REPLACE becuase tags can me lot more then I thought.
Please respond as soon as possible..Thanks for all your help!!
Anuj Sharmathank you all, but my code is only html no xml , and is other application that save in table
<html><head><title>Aprovação de ARC</title></head><body><font face=arial size=2><b>974-17016/ugadiego-2013</b></font><br><br><table border=0><tr><td><b><font face=arial size=1>Data da Abertura</font></b></td> <td><font face=arial size=1>8/3/2013</font></td><tr><td><b><font face=arial size=1>Quebra Produtividade</font></b></td> <td><font face=arial size=1>Sim</font></td><tr><td><b><font face=arial size=1>Quantidade</font></b></td> <td><font face=arial size=1>17,5</font></td><tr><td><b><font face=arial size=1>Valor</font></b></td> <td><font face=arial size=1>R$ 17496</font></td><tr><td><b><font face=arial size=1>Forma de Indenização</font></b></td> <td><font face=arial size=1>Nota de Crédito</font></td><tr><td><b><font face=arial size=1>Observação</font></b></td> <td><font face=arial size=1>Evidenciado a não conformidade do produto em visita a cliente pela assessoria agronômica e qualidade.
Produto apresenta-se empedrado com desuniformidade de grânulos e por consequência geração de finos e falha de óleo.
Produto expedido com GDAP.
Bonificar o cliente em 10% do valor da compra = R$ 17.496,00 ou em toneladas e fertilizantes que podem ficar em forma de crédito para o cliente retirar em fertilizante para o plantio da soja. Conforme relatório do Sr. Ademilson Palharin em anexo.</font></td><tr><td><b><font face=arial size=1>Centro de Custo</font></b></td> <td><font face=arial size=1>CAS1I4671 - MISTURA E ENSAQUE I </font></td></table><hr><font face=arial size=2><b>Favor incluir uma Observação (Se necessário) e selecionar o botão desejado para aprovar ou reprovar essa Indenização.</b></font><FORM ACTION='http://10.176.10.123/pgAprovaARCServidor.asp' METHOD='GET' ><font face=arial size=2><div>Observações:</div><textarea name='txtObs' rows='4' cols='60' maxlength='4000'></textarea><br><br><div><input type='submit' value='Aprovar' name='acao'> <input type='submit' value='Reprovar' name='acao'></div></font><br><hr><font face=arial size=2 >Essa é uma mensagem automática.<br>Favor não responder esse email</font><hr><input type='hidden' name='cdARC' value='17016' ><input type='hidden' name='cdSeq' value='1' ><input type='hidden' name='cdFase' value='Indenizacao' ><input type='hidden' name='dsResp' value='ustrenat' ><input type='hidden' name='dsCargo' value='Vice Presidência' ><input type='hidden' name='dsSolic' value='LESIANE CIESLAK' ><input type='hidden' name='index' value='3' ><input type='hidden' name='rowatu' value='3' ></FORM></body></html>using oracle 9.2.08
Edited by: muttleychess on Mar 19, 2013 11:36 AM -
Method to Format a string column containing HTML tags as simple string.
Hello,
I am working with formating a string column which holds Html tags.
I want to remove these tags from the actual data which has to be shown on the BI Publisher report.
Can you suggest how can we format this in the DataSet designer of BI publisher so that my data is recognised on the Layout designer.
I have been trying to create an expression using the "Add Element by Expression" option to format this html tag data as normal string without the tags.
Can you suggest if this is the correct method to do this.
I found this below code being used in an existing DateSet but i am not able to recreate a similar formating on this kind of data column.
<![CDATA' || '['|| TO_CLOB(SUCCESS_CRITERIA) || ']' || ']>
Kindly suggest if you have any idea on the above mentioned issue.
Thanks,
ShwetaAnd read this:
Navigate yourself around pitfalls related to the Runtime.exec() method
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
Hii
I have a field which is stored like this:
33-1A JALAN 8/125D||chr(13)||57100 DESA PETALING||chr(13)|| KUALA LUMPUR
Pls help me to write a regular expression to remove the leading space in KUALA LUMPUR
Thanking You
JimIs the rule to
<ul><li>Remove all spaces immediately preceding any occurrence of 'KUALA LUMPUR'</li>
<li>Remove all spaces immediately preceding the last field delimited by '||'</li>
<li>Remove all spaces immediately preceding the fifth field delimited by '||'</li>
<li>Remove all spaces following any occurrence of '||'</li>
<li>Something else?</li></ul>
Maybe you are looking for
-
Smartform font spacing Issue when using SAP printer name
Hi Friends, I am facing some spacing issues when printing a form using SAP printer name. If I use LOCL then the output comes perfectly but when I use the SAP printer name the space between characters are getting widened and so the alignment of each c
-
Powering on MacBook without opening lid
So if I'm using my MacBook with an external monitor, keyboard and mouse, is there no way to turn it on without opening the lid? If not, seems like poor decide. Excuse me if this is a topic that's already been debated to death, but it's a new problem
-
Fiori launchpad designer: missing tile templates
Dear all, We have installed the PPM Fiori apps on our system; we have managed to get these apps on the launchpad. Now we want to add a custom app to the catalog. If we start the launchpad designer and click on the catalog and then on the "+" to add a
-
My kid down loaded mackeeper and now I can not get rid of it. I have tried all techniques suggesting on several sites and still can not empty the trash can. keep getting error code -8003. Help.
-
Hi, We are developing an Enterprise application, using JSP pages, Servlets and EJBs. All EJB development is handled by one developer and I do the web tier development (JSPs, Servlets and other required Java classes). We are using Oracle Container for