using regular expression to change to uppercase, how to?

I want to use regular expression to change some string to its standard, for example:
" tran dinh thang "
-> "Tran Dinh Thang"
It means, I must clear all needless spaces, and change some letters to uppercase.
Please, give me some ideas!
Thanks so much!
#include <ctype.h> and use toupper() to set a character to upper case.
but i want to use regular expression, it is provided in header file <regex>, something like /.#$*()()~
Regular expressions are useful for pattern matching, not to change the contents of a string.
<regex> is not a standard header
The stream library can be used to do what you are trying very easily
i hope this code helps you.
i try running
it is ok
good luck.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include"stdafx.h"
#include<iostream>
using namespace std;
void correct(char *s)
{
	char last=32;//space=32;the first element 
	int j=0;
	for(int i=0;s[i];i++)
	{
		char c=s[i];
		if(last==32)
		{
			if(c==32) continue;
			if(c>='a'&&c<='z')//(a to z)
				c-=32;//Example:a->A,z->Z......
		}
		else
		{
			if(c>='A'&&c<='Z')
				c+=32;
		}
		s[j++]=last=c;
	}//end of for
if(last==32&&j!=0)
{
	j--;
	s[j]='\0';//NULL;
}//Finish
}

result
1
2
3
Input your char:tuan bach khoa ha noi
After correcting:Tuan Bach Khoa Ha Noi
Press any key to continue...
Last edited on
Topic archived. No new replies allowed.