473,614 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reg Expressions

Can we pad a string with spaces using regular expressions?

Ex: I have a string str = "ABC", I want to pad spaces to the total
string length 10 like "ABC "

how to achieve this using reqular expressions in VB.NET?

Oct 18 '05 #1
2 1540
The short answer to your question is yes, but why not just do something like
this?
Dim str As String = "ABC".PadRight( 10, " ")

HTH

Craig

<kr*********@gm ail.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
Can we pad a string with spaces using regular expressions?

Ex: I have a string str = "ABC", I want to pad spaces to the total
string length 10 like "ABC "

how to achieve this using reqular expressions in VB.NET?

Oct 18 '05 #2
<kr*********@gm ail.com> wrote:
Can we pad a string with spaces using regular expressions?
Possibly. The question which springs to mind is why on earth you'd want
to though. There's a perfectly good method for right-padding in the
String class though.
Ex: I have a string str = "ABC", I want to pad spaces to the total
string length 10 like "ABC "


Just use str=str.PadRigh t(10);

Or is there a reason why you particularly *need* to use regular
expressions?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
4385
by: Raymond Hettinger | last post by:
Peter Norvig's creative thinking triggered renewed interest in PEP 289. That led to a number of contributors helping to re-work the pep details into a form that has been well received on the python-dev list: http://www.python.org/peps/pep-0289.html In brief, the PEP proposes a list comprehension style syntax for creating fast, memory efficient generator expressions on the fly: sum(x*x for x in roots)
1
4162
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
5
1905
by: jens | last post by:
I was wondering if anyone could tell be whether it's possible to instruct preg_match not to save subexpressions matches under 0, 1...n keys when using named subexpressions; I.e instruct preg_named to matched under their names only, and not under their numbers. E.g. take the following example: <pre style="width:100%;text-align:justify">...
7
11431
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And #11/2/2003# And VehicleID='00000000' And BattID='LKO500HF'. I need to use the records returned to populate text boxes, but the data requires further manipulation. I attempting to use expressions in the control source
2
5038
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I have to use all the expressions seperately? Here are my regular expressions that check for valid email address and link Dim Expression As String =
4
5158
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
56
3957
by: Luke Matuszewski | last post by:
I am designing the library, which will hidden all its functions within singleton object ... So for clients they will use it like . eg. system.getElementWithId('ruler'); At library side, i will use constructs like follows (at global scope) eg.
2
2007
by: aarklon | last post by:
Hi all, Recently i was reading a c book which contained a section called C pitfalls. it had a paragraph on the following lines:- ------------------------------------------------------------------- using nonconstant expressions in an initializer list -------------------------------------------------------------------
1
4376
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find the first regular expression that matches the string. I've gor the regular expressions ordered so that the highest priority is first (if two or more regular expressions match the string I want the first one returned) The code that does this has...
3
2222
by: RobG | last post by:
There has been a discussion on the iPhone web development group where an opinion has been expressed that function expressions are bad for performance and can be avoided by using function declarations. For example (in a trivial case, the function body would do processing depending on various parameters passed) instead of: function foo(x) { var a = function(){x}; return a;
0
8623
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8429
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 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7091
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6088
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4050
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4121
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2566
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
1
1745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.