473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

searching pattern and replace it with string

ashitpro
542 Expert 512MB
I am doing little automation stuff and come across this situation.

I have a xml file and it contains nodes like:

Expand|Select|Wrap|Line Numbers
  1. <property name="SERVER_URI" type="STRING" value="172.18.28.106:3333/fab/bin/capability"/>
I want to search for such patterns and replace the ip:port dynamically..

Any help?
Aug 17 '10 #1

✓ answered by Oralloy

A lot depends on what you can expect, but this should be close...
Expand|Select|Wrap|Line Numbers
  1. s{(<property [^>]*value="(HTTP://)?)[^"]+:\d+}{$1$newIpPort}i
  2.  
Assuming I haven't made a mistake with the meta-character status of "<", ">", and "$1".

Also, if you're being really careful, you might want to look on CPAN for the pre-defined patterns modules. There's a good one that captures the "host:port" specification according to the specifications.

Luck.

1 1238
Oralloy
988 Expert 512MB
A lot depends on what you can expect, but this should be close...
Expand|Select|Wrap|Line Numbers
  1. s{(<property [^>]*value="(HTTP://)?)[^"]+:\d+}{$1$newIpPort}i
  2.  
Assuming I haven't made a mistake with the meta-character status of "<", ">", and "$1".

Also, if you're being really careful, you might want to look on CPAN for the pre-defined patterns modules. There's a good one that captures the "host:port" specification according to the specifications.

Luck.
Aug 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
4
by: lucky | last post by:
hi there!! i'm looking for a code snipett wich help me to search some words into a particular string and replace with a perticular word. i got a huge data string in which searching traditional...
5
by: olaufr | last post by:
Hi, I'd need to perform simple pattern matching within a string using a list of possible patterns. For example, I want to know if the substring starting at position n matches any of the string I...
10
by: ksrajalakshmi | last post by:
Hai , in a textbox am having text as "(20/100)+pay1*pay2" .it's a formula. and stored in a particular variable. string strformula="(20/100)+pay1*pay2" ; i've to substitute the value of the...
2
by: Evan | last post by:
Hey, I posted this yesterday, but no one had any ideas? C'mon now, I know this isn't that hard, i'm just a little new to javascript, and I can't quite figure this out. I searched and searched to...
1
by: Random Task | last post by:
Can someone help me by providing an example of how to replace / with \ in a string in xslt2. The characters / and \ seem to cause me grief ... I am trying the below code currently ... Any...
11
by: jarod1701 | last post by:
Hi, i'm currently trying to replace an unknown string using regular expressions. For example I have: user_pref("network.proxy.http", "server1") What do I have to do to replace the...
3
by: Dave2020 | last post by:
Im new to C++ and having a bit of a problem, I have a program, written in Visual C++, designed to take in data and then let a user search through it but while it lets the user search it never...
2
by: hogcia | last post by:
Hello! I've got a little problem - I'm writing a program in C++, which should compare a text input from keyboard with a regular expression and return what parttern was recognized and where. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.