473,549 Members | 3,113 Online

trim and REReplace

36 New Member
Hi,

I have this number: 000000000100000 00099B I need to remove the 0s before 10 and 99 and the alphabets like B after 99. I also need to replace the 0s between 10 and 99 by "-". I don't know how to use trim and Rereplace for these two numbers in this string. Any Idea? I appreciate it. Thanks
Feb 28 '08 #1
13 7756
acoder
16,027 Recognized Expert Moderator MVP
What's the pattern of these strings?

Replacing 0 and B is easy, but the 10 would make it more difficult because it has a 0!
Feb 28 '08 #2
cfmx2008
36 New Member
Agree. I have this problem too. The pattern is : 10 digits at the beginning of the string (for the 1st number) + 10 more digits after (for the 2ed number) + 1 alphabet.

I think we should clean the 4 or 5 first digits (0s) from the beginning of the string then leave the next 5 digits then insert our "-" and again clean the 4 or 5 next 0s and leave the rest and again clean the alphabet. What do you think?
Feb 28 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
That does make the problem easier because you have a consistent pattern.

However, I notice that in the example string you have 9 0s then 10. Is that correct or should it be 8 0s then a 10?
Feb 28 '08 #4
cfmx2008
36 New Member
In this example I have 9 0s. but remember the 1st 10 digits are belong to 1st number. In this case number is 1 so we have 9 0s left. The real number could be 111 then we will have 7 0s before the number.
Feb 28 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Use something like ^0+([1-9]+)(0+)([1-9]+)([A-Z]?)\$ and replace with \$1-\$3.

I haven't tested this with REReplace, but it should give you an idea. It matches 0s at the beginning followed by a number followed by 0s followed by a number followed by letters.
Feb 28 '08 #6
cfmx2008
36 New Member
Cool. I'll try it and let you know.
Feb 28 '08 #7
cfmx2008
36 New Member
Here is the code:
<cfset StreetNumber = REReplace(#Stre etNumber#,"^0+([1-9]+)(0+)([1-9]+)([A-Z]?)\$","\$1-\$3", "all")>

it will replace the whole StreetNumber by \$1-\$3. I tried it with trim() as well. It does the same. #StreetNumber# is 000000000100000 00099B
Feb 28 '08 #8
cfmx2008
36 New Member
I Got the exact pattern:

Street number ranges for near matches are returned in the following fixed-width format:

START RANGE (10 bytes) + END RANGE (10 bytes) + OEB code (1 byte) left-padded with zeros

Secondary (apartment) ranges for near matches are returned in the following fixed-width format:

START RANGE (8 bytes) + END RANGE (8 bytes) + OEB code (1 byte) left-padded with zeros

The OEB is “odd-even-both” code, meaning that the range either contains all Odd numbers, Even numbers, or Both.

In our example,

"00000000010000 000099B" means “buildings 1-99 Both odd and even”, i.e. {1,2,3,4,…. 98,99}

As you see, all we need to do is chop off all leading zeros in each of the range blocks.

Please don't give up on me:-)
Feb 28 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
Sorry, \$1-\$3 was JavaScript (and possibly other languages) notation for back-referencing. In Coldfusion, it's "\1-\3".
Feb 28 '08 #10

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

Similar topics

 22 12728 by: Simon | last post by: Hi, I have written a function to trim char *, but I have been told that my way could be dangerous and that I should use memmove(...) instead. but I am not sure why my code could be 'dangerous' or even why there could be a problem. here is the code //////// 5 33285 by: Alex Vassiliev | last post by: Hi all. Just wanted to share two handy RegEx expressions to strips leading and trailing white-space from a string, and to replace all repeated spaces, newlines and tabs with a single space. * JavaScript example: String.prototype.trim = function() { // Strip leading and trailing white-space 12 47528 by: Robert Mark Bram | last post by: Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*\$/g, ''); } The problem is that this doesn't trim instances of the " " char - the non breaking space. Can this be represented in a grep statement at 3 2732 by: FlyerN87 | last post by: For some reason this command will not trim the names shown in the fields listed. I'm trying to do this in a text box on a report. I've done this fairly succesfully in other reports but I must have done something wrong here.... I've tried both of these... =Trim( & ) =Trim( &", "& ) 11 5335 by: Darren Anderson | last post by: I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not (strIn.Substring(410, 10).Trim = "") Then 'Something processed Else 'Something processed 7 4209 by: Sascha Herpers | last post by: Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two faster? Is there a general rule/opinion to prefere members over functions? Thanks for any hint. 22 9717 by: Terry Olsen | last post by: I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I thought I'd change it to the VB ..NET method "String.Trim" but that throws an object exception. Which brings the question: is it compliant to use... 1 20652 by: arsaral | last post by: Hi, Here is an extension of MSDN's trim right example to trim left-right... First subroutines then the calling structure is given below... Cheers. Ali Riza SARAL //************************************************************* 31 2872 by: rkk | last post by: Hi, I've written a small trim function to trim away the whitespaces in a given string. It works well with solaris forte cc compiler, but on mingw/cygwin gcc it isn't. Here is the code: char *trim(char *s) { char *begin,*end; begin = s; 0 7446 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language... 0 7718 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ... 0 7956 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that... 1 7470 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For... 0 7809 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the... 1 5368 by: isladogs | last post by: The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes... 0 5088 by: conductexam | last post by: I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert... 0 3498 by: TSSRALBI | last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in... 1 1936 by: 6302768590 | last post by: Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.