{
    "mode": "pydoc",
    "parameter": "expr",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/expr/json",
    "generated": "2026-06-02T15:00:52Z",
    "sections": [],
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Evaluate expressions and manipulate strings.",
        "examples": [
            {
                "description": "Get the length of a specific string",
                "command": "expr length \"{{string}}\""
            },
            {
                "description": "Get the substring of a string with a specific length",
                "command": "expr substr \"{{string}}\" {{from}} {{length}}"
            },
            {
                "description": "Match a specific substring against an anchored pattern",
                "command": "expr match \"{{string}}\" '{{pattern}}'"
            },
            {
                "description": "Get the first char position from a specific set in a string",
                "command": "expr index \"{{string}}\" \"{{chars}}\""
            },
            {
                "description": "Calculate a specific mathematic expression",
                "command": "expr {{expression1}} {{+|-|*|/|%}} {{expression2}}"
            },
            {
                "description": "Get the first expression if its value is non-zero and not null otherwise get the second one",
                "command": "expr {{expression1}} \\| {{expression2}}"
            },
            {
                "description": "Get the first expression if both expressions are non-zero and not null otherwise get zero",
                "command": "expr {{expression1}} \\& {{expression2}}"
            }
        ]
    }
}