Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whitespace 1

Status
Not open for further replies.

Edge118

Programmer
Jun 15, 2004
104
US
In regular expressions, does a tab count as white space? If so, how many spaces does it count as? (1?)


Thanks for your help.


RB
 
a tab is one character in regexp
standard it take 8 spaces

:) guggach
 
like all other characters a tab is only a single character

this script, for example, shows the ASCII (American Standard Code for Information Interchange) value and the associated character

Code:
#!/usr/bin/perl

for ($x=32; $x<=255; $x++) {
  print "$x - ".chr($x)."\n";
}

the output it gives is:-

Code:
[blue]32 -  
33 - !
34 - "
35 - #
36 - $
37 - %
38 - &
39 - '
40 - (
41 - )
42 - *
43 - +
44 - ,
45 - -
46 - .
47 - /
48 - 0
49 - 1
50 - 2
51 - 3
52 - 4
53 - 5
54 - 6
55 - 7
56 - 8
57 - 9
58 - :
59 - ;
60 - <
61 - =
62 - >
63 - ?
64 - @
65 - A
66 - B
67 - C
68 - D
69 - E
70 - F
71 - G
72 - H
73 - I
74 - J
75 - K
76 - L
77 - M
78 - N
79 - O
80 - P
81 - Q
82 - R
83 - S
84 - T
85 - U
86 - V
87 - W
88 - X
89 - Y
90 - Z
91 - [
92 - 93 - ]
94 - ^
95 - _
96 - `
97 - a
98 - b
99 - c
100 - d
101 - e
102 - f
103 - g
104 - h
105 - i
106 - j
107 - k
108 - l
109 - m
110 - n
111 - o
112 - p
113 - q
114 - r
115 - s
116 - t
117 - u
118 - v
119 - w
120 - x
121 - y
122 - z
123 - {
124 - |
125 - }
126 - ~
127 - 
128 - Ä
129 - Å
130 - Ç
131 - É
132 - Ñ
133 - Ö
134 - Ü
135 - á
136 - à
137 - â
138 - ä
139 - ã
140 - å
141 - ç
142 - é
143 - è
144 - ê
145 - ë
146 - í
147 - ì
148 - î
149 - ï
150 - ñ
151 - ó
152 - ò
153 - ô
154 - ö
155 - õ
156 - ú
157 - ù
158 - û
159 - ü
160 - †
161 - °
162 - ¢
163 - £
164 - §
165 - •
166 - ¶
167 - ß
168 - ®
169 - ©
170 - ™
171 - ´
172 - ¨
173 - ?
174 - Æ
175 - Ø
176 - 8
177 - ±
178 - =
179 - =
180 - ¥
181 - µ
182 - ?
183 - ?
184 - ?
185 - p
186 - ?
187 - ª
188 - º
189 - O
190 - æ
191 - ø
192 - ¿
193 - ¡
194 - ¬
195 - v
196 - ƒ
197 - ˜
198 - ?
199 - «
200 - »
201 - …
202 -  
203 - À
204 - Ã
205 - Õ
206 - Œ
207 - œ
208 - –
209 - —
210 - “
211 - ”
212 - ‘
213 - ’
214 - ÷
215 - ?
216 - ÿ
217 - Ÿ
218 - /
219 - €
220 - ‹
221 - ›
222 - ?
223 - ?
224 - ‡
225 - ·
226 - ‚
227 - „
228 - ‰
229 - Â
230 - Ê
231 - Á
232 - Ë
233 - È
234 - Í
235 - Î
236 - Ï
237 - Ì
238 - Ó
239 - Ô
240 - ?
241 - Ò
242 - Ú
243 - Û
244 - Ù
245 - i
246 - ˆ
247 - ˜
248 - ¯
249 - ?
250 - ?
251 - °
252 - ¸
253 - ?
254 - ?
255 - ?[/blue]

if you wanted to know what ASCII value a tab is you can do this:-

Code:
#!/usr/bin/perl

print ord "\t";

it gives the value 9 - this is using ordinal

Hope this has been of some use!


Kind Regards
Duncan
 
The reason for the above is this:- each character is stored as 1 bit (bit = binary digit). 1 bit is comprised of 8 bytes. This works in binary (either 1 or 0). So the following takes place...

Code:
128   64    32    16    8     4     2     1
———————————————————————————————————————————
0     0     0     0     1     0     0     1

So your tab character would be 00001001 in binary - which makes 9 if you add it up


Kind Regards
Duncan
 
One more thing... if you add up 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 you get 255. Hence an 8-bit code, i.e. 1-byte, can store any one of 256 possible values. This can be a character on a keyboard or it could be a particular colour on a video card display. Remember the 8-bit video = 256 colours.

1 bit = 2 -> monochrome video display
2 bit = 4
3 bit = 8
4 bit = 16 -> CGA colour graphics
5 bit = 32
6 bit = 64 -> EGA colour graphics
7 bit = 128
8 bit = 256 -> keyboard character-set mapping & first decent video display
9 bit = 512
10 bit = 1024
11 bit = 2048
12 bit = 4096
13 bit = 8192
14 bit = 16384
15 bit = 32768 -> high colour - Sony Playstation 1 graphics
16 bit = 65536 -> high colour
17 bit = 131072
18 bit = 262144
19 bit = 524288
20 bit = 1048576
21 bit = 2097152
22 bit = 4194304
23 bit = 8388608
24 bit = 16777216 - true colour (photo-realistic) video display


thanks for the star


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top