m4_string.hlp

来自「是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到」· HLP 代码 · 共 154 行

HLP
154
字号
{smcl}
{* 31mar2005}{...}
{cmd:help m4 string}
{hline}
{* index string functions}{...}

{title:Title}

{p 4 4 2}
{bf:[M-4] string -- String manipulation functions}


{title:Contents}

{col 5}   [M-5]
{col 5}Manual entry{col 22}Function{col 35}Purpose
{col 5}{hline}

{col 5}   {c TLC}{hline 9}{c TRC}
{col 5}{hline 3}{c RT}{it: Parsing }{c LT}{hline}
{col 5}   {c BLC}{hline 9}{c BRC}

{col 7}{bf:{help mf_tokens:tokens()}}{...}
{col 22}{cmd:tokens()}{...}
{col 35}obtain tokens (words) from string

{col 7}{bf:{help mf_strmatch:strmatch()}}{...}
{col 22}{cmd:strmatch()}{...}
{col 35}pattern matching

{col 5}   {c TLC}{hline 19}{c TRC}
{col 5}{hline 3}{c RT}{it: Length & position }{c LT}{hline}
{col 5}   {c BLC}{hline 19}{c BRC}

{col 7}{bf:{help mf_strlen:strlen()}}{...}
{col 22}{cmd:strlen()}{...}
{col 35}length of string

{col 7}{bf:{help mf_strpos:strpos()}}{...}
{col 22}{cmd:strpos()}{...}
{col 35}find substring within string

{col 7}{bf:{help mf_indexnot:indexnot()}}{...}
{col 22}{cmd:indexnot()}{...}
{col 35}find character not in list

{col 5}   {c TLC}{hline 9}{c TRC}
{col 5}{hline 3}{c RT}{it: Editing }{c LT}{hline}
{col 5}   {c BLC}{hline 9}{c BRC}

{col 7}{bf:{help mf_substr:substr()}}{...}
{col 22}{cmd:substr()}{...}
{col 35}extract substring

{col 7}{bf:{help mf_strupper:strupper()}}{...}
{col 22}{cmd:strupper()}{...}
{col 35}convert to uppercase
{col 22}{cmd:strlower()}{...}
{col 35}convert to lowercase
{col 22}{cmd:strproper()}{...}
{col 35}convert to proper case

{col 7}{bf:{help mf_strtrim:strtrim()}}{...}
{col 22}{cmd:strltrim()}{...}
{col 35}remove leading blanks
{col 22}{cmd:strrtrim()}{...}
{col 35}remove trailing blanks
{col 22}{cmd:strtrim()}{...}
{col 35}remove leading and trailing blanks

{col 7}{bf:{help mf_subinstr:subinstr()}}{...}
{col 22}{cmd:subinstr()}{...}
{col 35}substitute text
{col 22}{cmd:subinword()}{...}
{col 35}substitute word

{col 7}{bf:{help mf_strdup:strdup()}}{...}
{col 22}{cmd:*}{...}
{col 35}duplicate string

{col 7}{bf:{help mf_strreverse:strreverse()}}{...}
{col 22}{cmd:strreverse()}{...}
{col 35}reverse string

{col 5}   {c TLC}{hline 19}{c TRC}
{col 5}{hline 3}{c RT}{it: ASCII translation }{c LT}{hline}
{col 5}   {c BLC}{hline 19}{c BRC}

{col 7}{bf:{help mf_strofreal:strofreal()}}{...}
{col 22}{cmd:strofreal()}{...}
{col 35}convert real into string

{col 7}{bf:{help mf_ascii:ascii()}}{...}
{col 22}{cmd:ascii()}{...}
{col 35}obtain ASCII codes of string
{col 22}{cmd:char()}{...}
{col 35}make string from ASCII codes

{col 5}{hline}


{title:Description}

{p 4 4 2}
The above functions are for manipulating strings.  Strings in Mata are 
strings of ASCII characters, usually the printable characters, but Mata 
enforces no such restriction.  In particular, strings may contain 
binary 0.


{title:Remarks}

{p 4 4 2}
In addition to the above functions, two operators are especially useful 
for dealing with strings.

{p 4 4 2}
The first is {cmd:+}.  Addition is how you concatenate strings:

	: {cmd:"abc" + "def"}
	{res:abcdef}

	: {cmd:command = "list"}
	: {cmd:args = "mpg weight"}
	: {cmd:result = command + " " + args}
	: {cmd:result}
	{res:list mpg weight}

{p 4 4 2}
The second is {cmd:*}.  Multiplication is how you duplicate strings:

	: {cmd:5*"a"}
	{res:aaaaa}

	: {cmd:"b"*3}
	{res:bbb}

	: {cmd:indent = 20}
	: {cmd:title = indent*" " + "My Title"}
	: {cmd:title}
        {res:                    My Title}


{title:Also see}

{p 4 13 2}
Manual:  {hi:[M-4] string}

{p 4 13 2}
Online:  help for 
{bf:{help m4_intro:[M-4] intro}},
{bf:{help mata:[M-0] intro}}
{p_end}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?