|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hello All,
I've been away from the boards for a while, but I have a question about regular expressions. So if there is an expert in this area, I have a question for you. I've created a label set (basically renamed words for different customer settings). To give you a better understanding, one client may choose to call their clients "distributors" while another may choose to call them "customers". I am also using these labels for language translation in some reports. So my question is, I need to replace the text in a string with these custom labels. Example: "This is a tool test to show it works." In this string I want to replace the word "to" with another string, lets say the word "and". But when I use the replace() function with the 'all' scope, it gives me this: "This is a andol test and show it works." I just want to change the word "to", not the beginning of the word "tool". This is the simplest of examples, but if I could find a way to search for whole words, rather than a substring, it would work great for me. I assume that regular expressions can do this somehow with the REReplace() function, I just don't know RegEx well enough to do this. Any and all help will be greatly appreciated. Thanks, Dan |
|
#2
|
|||
|
|||
|
Try ReReplaceNoCase and the regex "\bto\b".
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
Once again kiteless, you provide a solution. Thank you, it worked like a charm. Who knew it would be this simple though, I really need to study some regex. Thanks, Dan |
|
#4
|
|||
|
|||
|
This all worked great, but now it has expanded. I am actually manipulating an HTML dump that gets stored in a cfsavecontent variable. I now want to exclude any and all tags (i.e. Table, TR, TD, etc..., basically anything between '<' and '>') I also want to exclude anything between the <style> and </style> tags so the display does not get altered by accident, so ultimately I am just changing the static text that gets displayed to the client. Can this be done with RegEx, or do I have to employ some if/else funtionality to do what I need?
As always, any help is appreciated. Thanks, Dan |
|
#5
|
|||
|
|||
|
|
|
#6
|
|||
|
|||
|
Quote:
Hi Kiteless, I actually already looked at that, but that function seems to actually strip the tags(you pointed me to cflib.org a while back and have used numerous functions from there). I may be able to still use it to change all the tags, commit my own changes, and then change all the tags back. I want to keep the tags intact, so I will let you know how it goes. Thanks again, Dan |
|
#7
|
|||
|
|||
|
When you said "exclude the tags" I thought you meant remove them. The function will take a list of tags to exclude if that will work. What, exactly, are you trying to strip out?
|
|
#8
|
|||
|
|||
|
Quote:
Sorry, I should have said ignore. I want to ignore anything between '<' and '>', and I also want to ignore anything between '<style>' and '</style>'. Sorry for not being clearer the first time. To give a little more insight. I have created a tool to create a list of terms or words that you would want to replace with other custom terms. Since it is an area that can be used by an end user, I want to avoid any display issues. Example: if someone happens to put the word "table" in with a replacement word of "desk", it currently replaces the "<table" with "<desk" thus causing a display issue to the client. So, my hope was to ignore anything between the '<' and '>', and also '<style>' and '</style>'. This would negate any possibility of a display issue. I hope this explanation helps, it's fairly difficult to explain. I modified the script you posted, and created two parts, one to change the tag names, commit my change to all the terms in my logic, and then change all of the tag names back to normal. This seems to be working okay at the moment, but it leaves attribute names in tact, like "name, id, value, border, etc..." It just seems to me like there should be an easier way to do this with regex, but I could be wrong. Thanks, Dan |
|
#9
|
|||
|
|||
|
Yes I follow what you're trying to do, but this one goes beyond my simple regex skills I'm afraid. I'd speculate that this one is going to get rather complicated.
|
|
#10
|
|||
|
|||
|
Quote:
Thank you for your input, I will see if I can hunt down a regex expert to help me out. For now I will leave it with the tag renaming, odds are there won't be any issues, but you never know what a uneducated user might do. I am just trying to think further down the road here. Thanks again, Dan |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > RegEx Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|