我有以下文字:
id number primary key,
domain_name varchar2(100),
server_name varchar2(100),
create_date date,
create_by varchar2(100),
valid_from date,
valid_till date,
default_user varchar2(100),
default_password varchar2(100),
server_order number
我想替换number
和varchar2(100)
。基本上,我只想保留第一列。我知道我可以在Unix中用awk
来做,但是如何使用正则表达式呢?另外,可以从行的末尾搜索正则表达式吗?
(django_project) 16:19 ~/djangoPlay/theRightWay (master)$ cat /tmp/tx1 | awk '{print $1,","}
id ,
domain_name ,
server_name ,
create_date ,
create_by ,
valid_from ,
valid_till ,
default_user ,
default_password ,
server_order ,
答案 0 :(得分:0)
你想要的正则表达式是#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <stdio.h>
#include <OpenGL/gl.h>
#include <string.h>
using namespace std;
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
bool SetOpenGLAttributes()
{
// SDL_GL_CONTEXT_CORE gives us only the newer version, deprecated functions are disabled
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
return true;
}
int main( int argc, char* args[] )
{
SDL_Window* window = NULL;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//Create window
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL );
if( window == NULL )
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//creating new context
SDL_GL_CreateContext(window);
SetOpenGLAttributes();
SDL_GL_SetSwapInterval(1);
//cube front
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-.5, .5, -.5);
glVertex3f(.5, .5, -.5);
glVertex3f(.5, -.5, -.5);
glVertex3f(-.5, -.5, -.5);
glEnd();
//cube top
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(-.5,.5,-.5);
glVertex3f(.5, .5, -.5);
glVertex3f(.5, .5, .5);
glVertex3f(-.5, .5, .5);
glEnd();
//cube bottom
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-.5,-.5,-.5);
glVertex3f(.5, -.5, -.5);
glVertex3f(.5, -.5, .5);
glVertex3f(-.5, -.5, .5);
glEnd();
//cube right
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(.5, -.5, -.5);
glVertex3f(.5, -.5, .5);
glVertex3f(.5, .5, .5);
glVertex3f(.5, .5, -.5);
glEnd();
//cube left
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-.5, -.5, -.5);
glVertex3f(-.5, .5, -.5);
glVertex3f(-.5, .5, .5);
glVertex3f(-.5, -.5, .5);
glEnd();
//cube back
glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-.5, .5, .5);
glVertex3f(-.5, -.5, .5);
glVertex3f(.5, -.5, .5);
glVertex3f(.5, .5, .5);
glEnd();
glFlush();
SDL_GL_SwapWindow(window);
bool running = true;
while(running){
glRotatef(1, 1, 0, 0);
glFlush();
SDL_GL_SwapWindow(window);
SDL_Delay(100);
}
}
}
//Destroy window
//SDL_DestroyWindow( window );
//Quit SDL subsystems
//SDL_Quit();
return 0;
}
。这将捕获空间之前的任何东西(用于其他地方)并抛弃其余部分。
^(.*) .+$
表示&#34;从行的开头开始&#34;,^
表示结尾相同。
答案 1 :(得分:0)
你可以使用一个简单的s/ .*//g
,这将删除从每行第一个空格到行尾的所有内容。